OleDbErrorCollection.Item Property (Int32)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the error at the specified index.

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

public OleDbError this[
	int index
] { get; }

Parameters

index
Type: System.Int32

The zero-based index of the error to retrieve.

Property Value

Type: System.Data.OleDb.OleDbError

An OleDbError that contains the error at the specified index.

The following example displays each OleDbError within the OleDbErrorCollection collection.

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");
     }
  }

.NET Framework
Available since 1.1
Return to top
Show: