Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where is a list of ADODB error codes?
Message
De
05/09/2001 13:59:14
GW Gross
{Banned by Information Security Policy}
Lake Mary, Floride, États-Unis
 
 
À
Tous
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Titre:
Where is a list of ADODB error codes?
Divers
Thread ID:
00552695
Message ID:
00552695
Vues:
109
I am trying to enhance my error handling abilites with ADODB. I have found references that taught me how to loop thourgh and read the ADODB.Error collection. I even managed to write a generic procedure that loops through the Error collection for any ADO connection without needing to know its name. (I put the code below).

Here are the questions: I am currently using Access 97 and Access 2000, but I want to also be able to handle MSDE and SQL Server 7. Where can I find a list of the SQLState values that are returned? Where can I find a list of the Number and Descriptions that are returned? What is the NativeError value?

I have searched the MS site and the ADO site and cannot find a reference.

Any help would be appreciated. Also any advice on improving the error handling code would also be appreciated.

Generic ADO Error Collection Procedure:
Public Sub gAppADOErroCollection(ByRef strDBName As String, _
                                       errErrorCollection As Variant)
                                       
    'ADO Error Information
    Dim errLoop As Error
    Dim strError As String
    Dim iCounter As Integer
    
    'In case our adoConnection is not set or
    'there are other connection problems
    On Error Resume Next
    
        iCounter = 1
        strError = vbNullString
        
        'List the connection name in a header
        'This statement can be changed to write to an error log or 
        'a list box. 
        Debug.Print strDBName & " Errors"

        For Each errLoop In errErrorCollection

            With errLoop
              
                'Construct an error message string
                strError = "Error #" & iCounter & vbCrLf
                strError = strError & "ADO Error #" & .Number & vbCrLf
                strError = strError & "Description " & .Description & vbCrLf
                strError = strError & "Source " & .Source & vbCrLf
                strError = strError & "SQLState " & .SQLState & vbCrLf
                strError = strError & "NativeError " & .NativeError & vbCrLf
                Debug.Print strError
                iCounter = iCounter + 1

                'Code to handle a specific error.  
                'This is where I want to put a Case statement 
                'to handle more by raising specific errors
                'depending on what error was found.                 
                If .SQLState = "3022" Then
                    Debug.Print "Duplicate Key in SPOT"
                    Resume Next
                End If
                
            End With
        Next
    
                                    
End Sub
Thanks,
GW Gross

"You are blessed when you're content with just who you are - no more, no less." Matthew 5:5 (The Message)
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform