954,598 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need help to detect connection to MySQL Server

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 '' (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

dw8081
Newbie Poster
8 posts since Apr 2009
Reputation Points: 10
Solved Threads: 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

%>

hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244
 

Thx u Hielo,

this is what i need.

dw8081
Newbie Poster
8 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

You are welcome!

hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You