PDA

Click to See Complete Forum and Search --> : Why have 30 minute Connection Timeout?


Thom
Oct 27th, 2000, 02:06 PM
OK I ran accross the following tidbit from Jhausman:

'Either your command (most likely) or your connection is timing out. Luckily, you can set both:
'Dim g_Db As New ADODB.Connection
'g_Db.CommandTimeout = 1800 'about 30 mins
'g_Db.ConnectionTimeout = 1800

My question is, using ADO 2.5 which is better:

1) to set the timeout at 30 minutes OR

2) error trap for Err.Number = -2147217871 the CONNECTION TIMEOUT ERROR??

3) or do both!

I guess what I need to know is how often do we NEED the 30 min commandtimeout? The test program I'm working on requires an administrator to connect to the database 3-4 times when building a new test. I'm thinking I need to error trap each time AND maybe build in the longer timeout.

But what exactly happens during the 30 mins? Does the PC seem to 'freeze' if the connection takes a while? For now I'm planning to do both(unless someone with more knowledge can tell me a better way!)

Dim cnn1 As ADODB.Connection
Dim rs1 As ADODB.Recordset

Set cnn1 = New Connection
cnn1.ConnectionTimeout = 1800

cnn1.Open g_strConnection

If cnn1.State = adStateOpen Then
Set rs1 = cnn1.Execute(("SELECT TOP 1 etc"),,adCmdText)
Else
msgbox "Sorry! Unable to connect to the Database"
end if

ErrHandler:

If Err.Number = -2147217871
msgBox "Sorry! Could not connect to the Database"
Exit Sub
End If