0

Hi, i want to know if asp can detect connection to MySQL Server.

i have hosting (not dedicated server) but sometimes my website have error like this :
"[MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on '<MySQL SERVER place>' (10061)

can someone help me for some asp code to redirect into page "maintenance.asp" (maintenance.asp don't have connection to MySQL Server - so this page can show normally) when MySQL Server is down (connection fails).

THX

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by hielo
0
<%
On Error Resume Next
Dim sConnection, objConn , objRS

sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=Your_Mysql_DB; UID=mysql_username;PASSWORD=mysql_password; OPTION=3"

Set objConn = Server.CreateObject("ADODB.Connection")

objConn.Open(sConnection) 
If Err.Number <> 0 Then
    Response.Redirect "maintenance.asp"
    Response.End
Else
    'continue coding here
    '...

    objConn.close
    Set objConn=Nothing
End If

%>

Edited by Reverend Jim: Fixed formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.