troubleshooting Question

attempting to reach dead sql server

Avatar of rivkamak
rivkamakFlag for United States of America asked on
ASPMicrosoft SQL Server 2005VB Script
10 Comments2 Solutions595 ViewsLast Modified:
I have a few sql servers running as backup.
I set up a check if statement, to try to connect.
for example, it tries to connect to sql1, if it connects use that connection string.
if it didn't connect, show skip the error and try to connect to sql2 etc.

Now I am running into a problem that while I am making an attempt to open a connection that really doesn't exist, it takes my server 30 seconds, probably until it hits a timeout, before continuing and trying the next server connection.

is there some other way i can test for open connection, that wont' take as long as that, to test to see if I can connect.

Set myConn = Server.CreateObject("ADODB.Connection")
On Error Resume Next attempt_app1

Set ADOErrors = myConn.Errors

On Error GoTo 0

If ADOErrors.Count = 0 then
	If myConn.State = 1 then 

		stringUse = attempt_app1
		openConnection = true
	End If
End If

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros