How to detect SQL SERVER ON LINE or OFF Line

Dear all

any one have case like me,

I have 1 database and install at 2 sql server. I still use ADODB connection to connect to SQL server not ADO.net ;The sql server2 is for backup in case sql server 1 off line.

The problem is:

1. how to detech SQL server 1 if the engine is no running ( OFF line ) by VB 2005 Code.

2. how to automatic switch from code VB2005 if one the SQL server is off .

Thanks for help

note : if you have code sample please include at your answer .. many many thanks



Answer this question

How to detect SQL SERVER ON LINE or OFF Line

  • ssfftt

    I running at SQL server 2000, but i want to know how from code VB2005 detect that SQL server1 ( engine SQL SERVER ) running .

    if use the VB6, the code use "state", but how at VB2005

    and how if I use ADO.net connection

    Thanks


  • prasad_8104

    Are you running SQL Server 2005 or 2000 If so and the 2nd server is only for backup/failsafe then you could set it up as a mirror, it has built in functionality to do this.

    Otherwise, it's fairly simple to check if a database is accessible - just try to connect to it and read the error messages returned.



  • How to detect SQL SERVER ON LINE or OFF Line