This documentation is archived and is not being maintained.

OleDbError Class

Collects information relevant to a warning or error returned by the data source. This class cannot be inherited.

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


[Visual Basic]
NotInheritable Public Class OleDbError
public sealed class OleDbError
public __gc __sealed class OleDbError
class OleDbError

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 the OleDb data adapter when an error occurs. An instance of OleDbError is created and managed by the OleDbErrorCollection class, which in turn is created by the OleDbException class.

If the severity of the error is too great, the server may close the OleDbConnection. However, the user can reopen the connection and continue.


[Visual Basic, C#, C++] The following example displays the properties of the OleDbError.

[Visual Basic] 
Public Sub DisplayOleDbErrorCollection(myException As OleDbException)
    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 DisplayOleDbErrorCollection(OleDbException 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 DisplayOleDbErrorCollection(OleDbException* myException) 
    for (int i=0; i < myException->Errors->Count; i++)
          String::Format( S"Index #{0}\nMessage: {1}\nNative: {2}\nSource:",
              myException->Errors->Item[i]->NativeError.ToString() ),
          String::Format( S"{0}\nSQL: {1}\n",
              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.OleDb

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

OleDbError Members | System.Data.OleDb Namespace | OleDbErrorCollection | OleDbException