OleDbException.Errors 属性

定义

获取一个或多个 OleDbError 对象集合,这些对象提供有关用于 OLE DB 的 .NET Framework 数据提供程序生成的异常的详细信息。

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 类的收集的实例。

示例

以下示例显示 OleDbError 集合中的每个 OleDbErrorCollection

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 包装器。

适用于

另请参阅