共用方式為


OleDbException.Errors 屬性

定義

取得一個或多個 OleDbError 物件的集合,提供由 .NET Framework Data Provider for OLE DB 所產生之例外狀況的相關詳細資訊。

public:
 property System::Data::OleDb::OleDbErrorCollection ^ Errors { System::Data::OleDb::OleDbErrorCollection ^ get(); };
public System.Data.OleDb.OleDbErrorCollection Errors { get; }
member this.Errors : System.Data.OleDb.OleDbErrorCollection
Public ReadOnly Property Errors As OleDbErrorCollection

屬性值

OleDbError 類別的已收集執行個體。

範例

下列範例會顯示集合內的每一個OleDbErrorOleDbErrorCollection

public void DisplayOleDbErrorCollection(OleDbException exception)
{
   for (int i=0; i < exception.Errors.Count; i++)
   {
      MessageBox.Show("Index #" + i + "\n" +
             "Message: " + exception.Errors[i].Message + "\n" +
             "Native: " + exception.Errors[i].NativeError.ToString() + "\n" +
             "Source: " + exception.Errors[i].Source + "\n" +
             "SQL: " + exception.Errors[i].SQLState + "\n");
   }
}
Public Sub DisplayOleDbErrorCollection(exception As OleDbException)
    Dim i As Integer

    For i = 0 To exception.Errors.Count - 1
        MessageBox.Show("Index #" + i.ToString() + ControlChars.Cr _
           + "Message: " + exception.Errors(i).Message + ControlChars.Cr _
           + "Native: " + exception.Errors(i).NativeError.ToString() + ControlChars.Cr _
           + "Source: " + exception.Errors(i).Source + ControlChars.Cr _
           + "SQL: " + exception.Errors(i).SQLState + ControlChars.Cr)
    Next i
End Sub

備註

類別 OleDbErrorCollection 一律包含至少一個 類別的 OleDbError 實例。

這是集合的 OleDbErrorCollection 包裝函式。

適用於

另請參閱