Public Sub errorTest()
Dim myConn As ADODB.Connection
Dim myErr As ADODB.Error
Dim strError As String
On Error GoTo myHandler
Set myConn = New ADODB.Connection
myConn.Open "nothing"
Set myConn = Nothing
Exit Sub
myHandler:
For Each myErr In myConn.Errors
strError = "Error #" & Err.Number & vbCr & _
" " & myErr.Description & vbCr & _
" (Source: " & myErr.Source & ")" & vbCr & _
" (SQL State: " & myErr.SQLState & ")" & vbCr & _
" (NativeError: " & myErr.NativeError & ")" & vbCr
If myErr.HelpFile = "" Then
strError = strError & " No Help file available"
Else
strError = strError & _
" (HelpFile: " & myErr.HelpFile & ")" & vbCr & _
" (HelpContext: " & myErr.HelpContext & ")" & _
vbCr & vbCr
End If
Debug.Print strError
Next
Resume Next
End Sub
|