Click here to Skip to main content
15,915,044 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello!
I am using following code to update current time to my SQL Server database every second. The code runs ok for sometimes but after certian time (not always) it returns error:

Server Timed Out !

Please advise.

C++
Private Sub tmrUpDate_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrUpDate.Tick
    DsServerTimeUPD.tblServerTime.Clear()
    taServerTimeUPD.Connection.ConnectionString += ";Password=" & vrSAPWD
    Me.taServerTimeUPD.Fill(Me.DsServerTimeUPD.tblServerTime)
    Dim drUpdServerTime As DataRow
    drUpdServerTime = DsServerTimeUPD.tblServerTime.Rows(0)
    drUpdServerTime.BeginEdit()
    drUpdServerTime.Item("ServerTime") = Now()
    drUpdServerTime.EndEdit()
    taServerTimeUPD.Update(DsServerTimeUPD.tblServerTime)
End Sub
Posted
Comments
José Amílcar Casimiro 7-May-14 12:17pm    
One of the strangest requirements that I have read in recent times.

Insufficient information.
Do you have another queries running over the same table?
How your code open and closes connections?
Maciej Los 7-May-14 12:51pm    
update current time to my SQL Server database every second - why???

1 solution

Please, read comments to the question. You did not provide enough information about issue and the reason you want to update ServerTime field every second. Nevertheless...

You really don't need this! Believe me!

To get SQL server time, see: Date and Time Data Types and Functions (Transact-SQL)[^].

Check this:
SQL
SELECT GETDATE(), SYSDATETIME(), SYSUTCDATETIME(), GETUTCDATE()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900