How to use ASP to redirect failed ADO connection to a backup SQL server
Use ASP to redirect failed ADO connection to a backup SQL server
on error resume next
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open MSCSSite.DefaultConnectionString
Set cmdTemp = Server.CreateObject("ADODB.Command")
cmdTemp.CommandType = adCmdText
Set cmdTemp.ActiveConnection = conn
' If the above ADO connection fails, then we check
' the error number, if it is not equal to 0, then we change
' the MSCSSite.DefaultConnectionString to one of the
' connection strings in the mscssite.connectionstringmap.
' For purposes of this example, the default database is
' SSCommerce and the backup is SSCommerce2
If Err.Number <> 0 Then
err.clear
mscssite.defaultconnectionstring = mcssite.connectionstringmap("SSCommerce2")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open MSCSSite.DefaultConnectionString
Set cmdTemp = Server.CreateObject("ADODB.Command")
cmdTemp.CommandType = adCmdText
Set cmdTemp.ActiveConnection = conn
End if
No comments:
Post a Comment