This documentation is archived and is not being maintained.

OdbcErrorCollection Class

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Collects all errors generated by the OdbcDataAdapter. This class cannot be inherited.

For a list of all members of this type, see OdbcErrorCollection Members.


[Visual Basic]
NotInheritable Public Class OdbcErrorCollection
   Implements ICollection, IEnumerable
public sealed class OdbcErrorCollection : ICollection, IEnumerable
public __gc __sealed class OdbcErrorCollection : public
   ICollection, IEnumerable
class OdbcErrorCollection implements ICollection,

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


This class is created by OdbcException to collect instances of the OdbcError class. OdbcErrorCollection always contains at least one instance of the OdbcError class.


[Visual Basic, C#, C++] The following example displays each OdbcError within the OdbcErrorCollection.

[Visual Basic] 
Public Sub DisplayOdbcErrorCollection(myException As OdbcException)
    Dim i As Integer
    For i = 0 To myException.Errors.Count - 1
        MessageBox.Show("Index #" + i.ToString() + ControlChars.Cr _
           + "Message: " + myException.Errors(i).Message + ControlChars.Cr _
           + "Native: " + myException.Errors(i).NativeError.ToString() + ControlChars.Cr _
           + "Source: " + myException.Errors(i).Source + ControlChars.Cr _
           + "SQL: " + myException.Errors(i).SQLState + ControlChars.Cr)
    Next i
End Sub

public void DisplayOdbcErrorCollection(OdbcException myException) 
   for (int i=0; i < myException.Errors.Count; i++)
      MessageBox.Show("Index #" + i + "\n" +
             "Message: " + myException.Errors[i].Message + "\n" +
             "Native: " + myException.Errors[i].NativeError.ToString() + "\n" +
             "Source: " + myException.Errors[i].Source + "\n" +
             "SQL: " + myException.Errors[i].SQLState + "\n");

    void DisplayOdbcErrorCollection(OdbcException* myException)
        for (int i=0; i < myException->Errors->Count; i++)
                S"Index # ", __box(i), 
                S"\n Message: ", myException->Errors->Item[i]->Message, 
                S"\n Native: ", myException->Errors->Item[i]->NativeError, 
                S"\n Source: ", myException->Errors->Item[i]->Source, 
                S"\n SQL: ", myException->Errors->Item[i]->SQLState, 

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Data.Odbc

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Data (in System.Data.dll)

See Also

OdbcErrorCollection Members | System.Data.Odbc Namespace | OdbcError | OdbcException