i SET MY CONNECTION TIMEOUT FROM A DEFULT VALUE OF 15 TO 1 SECOND, BUT WHEN THE CONNECTION IS MISSING TIMEOUT ACTUALLY TAKES ABOT 20 SECONDS, NOT 1 SECOND THAT IT WAS SET TO.
Public Sub Write_to_server()
Dim cnnConnection As New ADODB.Connection
Dim cmdCommand As New ADODB.Command
pstrSQLInsert = "INSERT INTO tblMyTable " & "(Recordtime,carrier,model)" & _
" VALUES ('" & pdatetime & "'" & "," & _
"'" & pstrCarrier & "'" & "," & _
"'" & pstrModel & "'"
On Error GoTo ErrLabel
cnnConnection.Provider = "sqloledb"
cnnConnection.Properties("Data Source".Value = Zebra_Auto40.mstrSql_Server
cnnConnection.Properties("Initial Catalog".Value = "MYDATABASE"
cnnConnection.Properties("User ID".Value = pstrValueUser
cnnConnection.Properties("Password".Value = pstrValuePassword
cnnConnection.ConnectionTimeout = 1
cnnConnection.Open
Set cmdCommand.ActiveConnection = cnnConnection
cmdCommand.CommandText = pstrSQLInsert
cmdCommand.CommandTimeout = 1
cmdCommand.Execute
cnnConnection.Close
Exit Sub
Public Sub Write_to_server()
Dim cnnConnection As New ADODB.Connection
Dim cmdCommand As New ADODB.Command
pstrSQLInsert = "INSERT INTO tblMyTable " & "(Recordtime,carrier,model)" & _
" VALUES ('" & pdatetime & "'" & "," & _
"'" & pstrCarrier & "'" & "," & _
"'" & pstrModel & "'"
On Error GoTo ErrLabel
cnnConnection.Provider = "sqloledb"
cnnConnection.Properties("Data Source".Value = Zebra_Auto40.mstrSql_Server
cnnConnection.Properties("Initial Catalog".Value = "MYDATABASE"
cnnConnection.Properties("User ID".Value = pstrValueUser
cnnConnection.Properties("Password".Value = pstrValuePassword
cnnConnection.ConnectionTimeout = 1
cnnConnection.Open
Set cmdCommand.ActiveConnection = cnnConnection
cmdCommand.CommandText = pstrSQLInsert
cmdCommand.CommandTimeout = 1
cmdCommand.Execute
cnnConnection.Close
Exit Sub