ODBC Connection Error Trapping 
Author Message
 ODBC Connection Error Trapping

I have a database that drives much of the content on my company's website.
The trouble is, if that SQL server goes down, there can be all kinds of
stupid error messages on the site, including on the front page.  I can't
find any really good information on trapping errors and doing "something
else" in case of a failure to connect to the ODBC datasource.  The error
happens when the statement

"Connection.Open "DSN={Datasource Name};UID={uid}""

gets parsed.  The specific error that I need to trap is "The database
appears to be unavailable"

I wish there was a way to test if the connection could be made, or a way to
know if it was busted, so that you could program in a different behaviour in
the event the database was down.  Any ideas? Pointers?

Thanks!

Dave Mays
Jedi Webmaster - Scala, Inc. - www.scala.com
"Remember - Street lights timed for 35 mph are also timed for 70 mph."



Mon, 04 Jun 2001 03:00:00 GMT  
 ODBC Connection Error Trapping
I assume that you are using Active Server Pages to generate HTML on your
server.

Use "On Error Resume Next" judiciously to trap errors.  For example:

<%
On Error Resume Next
Err.Clear
' do database operation here
If Err.Number <> 0 Then
    ' an error occurred, so do something appropriate.
End If
%>

Eric


Quote:
>I have a database that drives much of the content on my company's website.
>The trouble is, if that SQL server goes down, there can be all kinds of
>stupid error messages on the site, including on the front page.  I can't
>find any really good information on trapping errors and doing "something
>else" in case of a failure to connect to the ODBC datasource.  The error
>happens when the statement

>"Connection.Open "DSN={Datasource Name};UID={uid}""

>gets parsed.  The specific error that I need to trap is "The database
>appears to be unavailable"

>I wish there was a way to test if the connection could be made, or a way to
>know if it was busted, so that you could program in a different behaviour
in
>the event the database was down.  Any ideas? Pointers?

>Thanks!

>Dave Mays
>Jedi Webmaster - Scala, Inc. - www.scala.com
>"Remember - Street lights timed for 35 mph are also timed for 70 mph."



Tue, 05 Jun 2001 03:00:00 GMT  
 ODBC Connection Error Trapping
Use the on error resume next statement, and then after you execute your SQL
trans, examine the ado errors object, such as:
[Your connection].Errors.Count


Quote:
>I have a database that drives much of the content on my company's website.
>The trouble is, if that SQL server goes down, there can be all kinds of
>stupid error messages on the site, including on the front page.  I can't
>find any really good information on trapping errors and doing "something
>else" in case of a failure to connect to the ODBC datasource.  The error
>happens when the statement

>"Connection.Open "DSN={Datasource Name};UID={uid}""

>gets parsed.  The specific error that I need to trap is "The database
>appears to be unavailable"

>I wish there was a way to test if the connection could be made, or a way to
>know if it was busted, so that you could program in a different behaviour
in
>the event the database was down.  Any ideas? Pointers?

>Thanks!

>Dave Mays
>Jedi Webmaster - Scala, Inc. - www.scala.com
>"Remember - Street lights timed for 35 mph are also timed for 70 mph."



Sun, 24 Jun 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ODBC connections using ODBC

2. ODBC Error Trapping

3. ODBC Error trapping question

4. Error Trapping In ODBC

5. Trapping ODBC error codes

6. Trapping SQL Errors via ODBC

7. Trapping ODBC Errors in VB 4.0 - HOW ???

8. Trapping ODBC 2.0 errors in VB 3.0

9. Trapping ODBC Errors

10. Trapping ODBC Errors

11. Trapping ODBC Error

12. Trapping SQL Errors via ODBC

 

 
Powered by phpBB® Forum Software