Database connection error handling?

Results 1 to 2 of 2

Thread: Database connection error handling?

  1. #1
    Join Date
    Dec 1969

    Default Database connection error handling?

    Hello. How do I handle a database connection error using the connectionless approach?<BR>strDbPath = Server.MapPath(".") & "/xyz.mdb"<BR>ConnectStr = "Provider=Microsoft.Jet.OLEDB.4.0;data source="&strDBPath <BR>set conn=server.createobject("ADODB.connection")<BR>co ConnectStr<BR><BR>I want to catch the error when the database is somehow unavailable due to "file already opened" or "exclusively locked"...etc.<BR>Is there a way I can return some error code while I do<BR><BR>Thanks.

  2. #2
    Join Date
    Dec 1969

    Default RE: Database connection error handling?

    on error resume next<BR><BR>strDbPath = Server.MapPath(".") & "/xyz.mdb"<BR>ConnectStr = "Provider=Microsoft.Jet.OLEDB.4.0;data source="&strDBPath <BR>set conn=server.createobject("ADODB.connection")<BR>co ConnectStr<BR><BR>if err.number &#062; 0 then<BR> response.write "error :" & err.number<BR> err.number = 0<BR>end if

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts