Programmatically test if DB server is alive?

G

Guest

In ASP VBScript, is there a way to programmatically test if a SQL Server
database server is alive?

I want to use a connection string to a mirrored DB server in case the
primary DB server fails. This failover is easy in ASP.NET, which supports DB
mirroring and a the specification of a secondary server in its data
provider. I want to hack together the same thing for my classic ASP apps.
Any suggestions?

-KF
 
L

Luke Zhang [MSFT]

Hello,

To detect a Database is availeble, you may just open a connection to it and
catch possible error. For example:

Con.Open "Provider=SQLOLEDB; Data
Source=localhost;database=northwind;integrated security=SSPI"

If Err.Number <> 0 Then
...
Else
...

If there is any error after opening a connection, we can think this server
is not availeble currently and redirect to backup server.

Regards,

Luke Zhang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top