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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make + Test ADO connection to SQLServer

Status
Not open for further replies.

Roebuck

Technical User
Apr 23, 2003
14
0
0
GB
I am trying to make & test an ADO connection to SQLServer7. The routine works fine if the details in the connection string are correct, or if either the uid/pwd is wrong.

However if the server does not exist, the connection waits for approx 1 minute before returning the error:
"[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied."

I have changed the timeout settings but the 1 minute delay remains...

Please can somebody advise how can I get this error to occur sooner - within a couple of seconds would be good!

Thanks in advance


#####
Extract from code:

Dim cn As ADODB.Connection
Dim strCN As String
Dim blnSuccess as Boolean

Set cn = New ADODB.Connection

strCN = "driver={SQL Server};DSN=;server=168.128.1.5;database=Pubs;uid=user;pwd=;"

cn.ConnectionTimeout = 10
cn.Open strCN

If cn.State = 1 Then
blnSuccess = True
Else
blnSuccess = False
End If

cn.Close

Set cn = Nothing
#####
 

Thanks, but 'cn.ConnectionTimeout = 0' appears to prevent a timeout and will cause the connection attempt to wait for longer.

What I need is for the attempted connection to error as soon as possible when the server is unavailable (or the address is incorrect).

Is this possible?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top