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

<%
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

%>

Thx u Hielo,

this is what i need.

You are welcome!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.