The ADO Error object contains the most recent data access error from the data provider.
ADO provides an Error object that is similar to the Err object provided by VB/VBScript. The Err object detects any error generated and provides a lot of info but the ADO Error object provides two additional properties with info direct from the data provider
Note that VBS is limited to On Error Resume Next, On Error Resume 0, and the Err object. See also my article on VB Debugging.
EG:
Set cnn1 = Server.CreateObject("ADODB.Connection")
On Error Resume Next
'Error may occur but resumes on next line with error handling:
If Err Then
Response.Write "<p><b>VBScript Err Object:</b><br>" & _
"-Number: " & Err.Number & "<br>" & _
"-Description: " & Err.Description & "<br>" & _
"-Source: " & Err.Source & "<br>" & _
"-HelpFile: " & Err.HelpFile & "<br>" & _
"-HelpContext: " & Err.HelpContext & "</p>"
'The Error object may return multiple errors:
For i = 0 To cnn1.Errors.Count - 1
Response.Write "<p><b>ADO Error Object:</b><br>" & _
"-Number: " & Err.Number & "<br>" & _
"-Description: " & Err.Description & "<br>" & _
"-Source: " & Err.Source & "<br>" & _
"-HelpFile: " & Err.HelpFile & "<br>" & _
"-HelpContext: " & Err.HelpContext & "<br>"
"-SQLState: " & Err.SQLState & "<br>" & _
"-NativeError: " & Err.NativeError & "</p>"
Next
End If
ADO resets the ADO Error collection before every ADO call on each Connection object, thus the Error collection will only have errors from the most recent call.
| Properties | Methods | Events |
|---|---|---|
|
None | None |
Page Modified: (Hand noted: 2007-10-11 20:09:26Z) (Auto noted: 2007-11-17 06:47:02Z)