共用方式為


OleDbErrorCollection.Count 屬性

定義

取得集合中的錯誤數目。

public:
 property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer

屬性值

集合中的錯誤總數。

實作

範例

下列範例會顯示集合內的每一個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

適用於

另請參閱