SQL failover help...

Discussion in 'Databases' started by loanpipecom, Oct 1, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi All,


    My site connects to SQL2K. I the event the DB isn't available (ie-timeout), I'd like to have the site connect to another SQL2K server on another network. What I have tried so far is testing the err object as follows. In the event of an err, I change the connection string and try to set my connection object with that string to a DB I know for a fact is available.

    But this doesn't seem to work. Any ideas? Please take a look at my code and tell me what you think:

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Open database connection

    If IsObject(objConn) = False Then

    strConn = "PROVIDER=SQLOLEDB;Password=***;Persist Security Info=True;User ID=***;Initial Catalog=DB1;Data Source=DBServer1"

    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Provider = "SQLOLEDB.1"
    objConn.CommandTimeout = 3
    objConn.ConnectionString = strConn
    objConn.ConnectionTimeout = 3
    objConn.CursorLocation = 3

    objConn.Open
    If err <> 0 Then

    ''''''''''''''''''''''''''''''''''''''''''''''
    ' Lets connect to another db

    objConn.Close

    'Should email admin for db switch here!
    strConn = "PROVIDER=SQLOLEDB;Password=***;Persist Security Info=True;User ID=***;Initial Catalog=2;Data Source=DBServer2"

    objConn.Open
    If err <> 0 Then
    Session("SystemMsg") = "Databases not available!" &amp; err.description
    Session("SystemMsg") = "Sorry, All databases failed to connect!"
    response.redirect("../System-Error.asp")
    response.end
    End If

    ' Lets connect to another db
    ''''''''''''''''''''''''''''''''''''''''''''''
    End If

    End If

    ' Open database connection
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
     
  2. Bruce

    Bruce DiscountASP.NET Staff

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page