Hi All,
I have an update command within vba that occurs on worksheet_change of a workbook. It works by once something is typed into Excel a connection to the database is opened and I grab variables from the excel document to input into the database. This is my code:
The problem is that once in a while during the cmd1.Execute a user will get the Timeout Expired error.. There are 10 users using this report, which I don't presume is many. I am wondering why this occurs and how to avoid it? For some reason I think it is network congestion. I do have some code that fires off if that error occurs to retry the connection, it will retry it 6 times a total of 12 seconds then give the error again, and it still seems to occur. Any ideas what I can do?SQLConnect = "Provider=sqloledb;Integrated Security=SSPI;" & _"Data Source=NCCHAR9\PDS_SSQL; Database=MWPMO; " & _"Persist Security Info=False;" Conn1.ConnectionString = SQLConnect Conn1.CursorLocation = adUseClient Conn1.Mode = adModeReadWrite Conn1.Open Cmd1.ActiveConnection = Conn1 Cmd1.CommandText = "UPDATE " & tblnm & " SET " & varCol & " = NULL WHERE [ID] = " & varKey & "" Cmd1.Execute Cmd1.CommandText = "INSERT INTO Input_Changes(ID, TableName, ColumnName, OldData, NewData, UserID, DateTime) " _& "VALUES('" & varKey & "','" & tblnm & "','" & varCol & "','" & Oval1 & "','" & varData & "','" & username & "','" & Now() & "')" Cmd1.Execute
Conn1.Close
Set Conn1 = Nothing