I'm attempting to write a function that will catch the following error
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database "FaCom" requested by the login. The login failed.
/uploadtest/file2.asp, line 27
I'd like it to catch that error and output a message that says "DB Connection Error" Or something to that effect. However since this is my first attempt at catching errors its not working.
I've purposely set the OMS name incorrectly to figure how to catch the error.Code:<% On Error Resume Next OMS="FaCom" OfferID ="FC-Money" dim strSQL,Global_DBConnection,DSN,SQL,RS, Counter set Global_DBConnection=Server.CreateObject("ADODB.Connection") DSN="Driver={SQL Server};Server=.\SQL;Database="&OMS&";UID=sa;PWD=lynx111" Global_DBConnection.Open(DSN) SQL="SELECT * FROM OFFERS WHERE OFFERS_ID='"&OfferID&"' AND OFFERS_Inactive=0" 'response.write SQL &"<br>" Set RS = Global_DBConnection.execute(SQL) Do While Not RS.EOF Counter= Counter + 1 RS.Movenext Loop RS.close IF Counter<1 Then ErrorMessage = ErrorMessage & CurrentOrderID & ": " & OfferID & " - Invalid Offer Id or Inactive offer<br>" ErrorCount=ErrorCount+1 DispOrder=True End If If Err.Number='80004005' response.write "DB Connection Error" End If %>
Can anyone point me in the right direction? I've read up on it but I'm not finding the issue.




Reply With Quote