The Errors Collection : ADODB.Connection « Access « VBA / Excel / Access / Word






The Errors Collection

 
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

 








Related examples in the same category

1.Connection to database
2.Connect to current database
3.Creating a Connection Object
4.open up a schema with a provider to look at all the database objects
5.Connect to databse through URL
6.Connect to database with user name and password