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

RE: Programmatically test if DB server is alive? by lukezhan

lukezhan
Tue May 16 21:35:02 CDT 2006

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.)


Re: Programmatically test if DB server is alive? by kenfine

kenfine
Wed May 17 11:45:43 CDT 2006

Super, very helpful, thanks, Luke.

-KF


"Luke Zhang [MSFT]" <lukezhan@online.microsoft.com> wrote in message
news:FGChFqVeGHA.4672@TK2MSFTNGXA01.phx.gbl...
> 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.)
>