Programmatically test if DB server is alive?

Discussion in 'ASP General' started by Guest, May 16, 2006.

  1. Guest

    Guest 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
     
    Guest, May 16, 2006
    #1
    1. Advertising

  2. 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.)
     
    Luke Zhang [MSFT], May 17, 2006
    #2
    1. Advertising

  3. Guest

    Guest Guest

    Super, very helpful, thanks, Luke.

    -KF


    "Luke Zhang [MSFT]" <> wrote in message
    news:...
    > 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.)
    >
     
    Guest, May 17, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    558
    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=
    May 3, 2006
  2. Leon
    Replies:
    0
    Views:
    357
  3. Replies:
    0
    Views:
    281
  4. Skybuck Flying

    Call oddities: &Test() vs &Test vs Test

    Skybuck Flying, Oct 4, 2009, in forum: C Programming
    Replies:
    1
    Views:
    765
    Skybuck Flying
    Oct 4, 2009
  5. hisan
    Replies:
    1
    Views:
    1,411
    Dan Stromberg
    Jun 25, 2012
Loading...

Share This Page