Timeout property doed not seem to work for connection timeout. I set it to 1 second but actually it takes about 20 seconds. I am using Reference Active X Data Objects 2.6.
Dim cnn As New ADODB.Connection
Dim cnstring As String
cnstring = "Provider = SQLOLEDB;" & _
"DATA SOURCE =<server name>;" & _
"USER ID = <user id>;" & _
"PASSWORD =<password>;" & _
"INITIAL CATALOG = <database>;"
cnn.CommandTimeout = 1
cnn.Open cnstring
Dim cmd As New ADODB.Command
cmd.ActiveConnection = cnn
Debug.Print "Timeout on Connection: " & cnn.CommandTimeout
Debug.Print "Timeout on Command: " & cmd.CommandTimeout
Dim cnn As New ADODB.Connection
Dim cnstring As String
cnstring = "Provider = SQLOLEDB;" & _
"DATA SOURCE =<server name>;" & _
"USER ID = <user id>;" & _
"PASSWORD =<password>;" & _
"INITIAL CATALOG = <database>;"
cnn.CommandTimeout = 1
cnn.Open cnstring
Dim cmd As New ADODB.Command
cmd.ActiveConnection = cnn
Debug.Print "Timeout on Connection: " & cnn.CommandTimeout
Debug.Print "Timeout on Command: " & cmd.CommandTimeout