Did you find this useful?
Socialize it today.


ADO Capturing Errors

Monday, October 01, 2012

tags ADO

Troubleshooting errors within your ASP web application can be challenging sometimes. When working with ADO, the Error object can be used since it contains details about data access errors that have been generated during a single operation. ADO will generate one Error object for each error. Each Error object contains details of the specific error. To access the errors, you must refer to a specific connection. Here is an example on how we can loop through the Errors Collection:

Syntax

objErr.property

Properties

PropertyDescription
DescriptionReturns an error description
HelpContextReturns the context ID of a topic in the Microsoft Windows help system
HelpFileReturns the full path of the help file in the Microsoft Windows help system
NativeErrorReturns an error code from the provider or the data source
NumberReturns a unique number that identifies the error
SourceReturns the name of the object or application that generated the error
SQLStateReturns a 5-character SQL error code

Example

<%
oConn.Execute sql
if err<>0 then
    for each objErr in oConn.Errors
      response.write("<table>")
      response.write("<tr><td>Description</td><td>")
      response.write(objErr.Description & "</td></tr>")
      response.write("<tr><td>Help context</td><td>")
      response.write(objErr.HelpContext & "</td></tr>")
      response.write("<tr><td>Help file</td><td>")
      response.write(objErr.HelpFile & "</td></tr>")
      response.write("<tr><td>Native error</td><td>")
      response.write(objErr.NativeError & "</td></tr>")
      response.write("<tr><td>Error number</td><td>")
      response.write(objErr.Number & "</td></tr>")
      response.write("<tr><td>Error source</td><td>")
      response.write(objErr.Source & "</td></tr>")
      response.write("<tr><td>SQL state</td><td>")
      response.write(objErr.SQLState & "</td></tr>")
      response.write("</table><br/><br/>")
    next
else
    <!-- No errors detected, proceed with ASP code -->
end if
%>

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

ADO Programmers Reference ADO: ActiveX Data Objects ADO Programming for Dummies