Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CODE!!! Help with ADO connection timeout

Status
Not open for further replies.

smcmanus

Technical User
Aug 1, 2001
25
CA
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;" & _
&quot;DATA SOURCE =<server name>;&quot; & _
&quot;USER ID = <user id>;&quot; & _
&quot;PASSWORD =<password>;&quot; & _
&quot;INITIAL CATALOG = <database>;&quot;

cnn.CommandTimeout = 1
cnn.Open cnstring
Dim cmd As New ADODB.Command
cmd.ActiveConnection = cnn
Debug.Print &quot;Timeout on Connection: &quot; & cnn.CommandTimeout
Debug.Print &quot;Timeout on Command: &quot; & cmd.CommandTimeout
 
'sets the COMMAND timeout:
cnn.CommandTimeout = 1

you didn't set the CONNECTION timeout:
cnn.CONNECTIONTimeout = 1
Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
One big problem is your dimension statement. Go ahead and Dim the object, but do not use the New keyword. Use a SET statement with the New keyword - this is what actually creates an instance of the object you are trying to use. Also remember to SET object = Nothing to release it....
Go Pack!! (I'm in Wisconsin)
-Geno
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top