OdbcException.Errors 属性

定义

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

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

属性值

OdbcError 类的收集的实例。

示例

以下示例显示 OdbcError 集合中的每个对象 OdbcErrorCollection

public void DisplayOdbcErrorCollection(OdbcException 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 DisplayOdbcErrorCollection(exception As OdbcException)
    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

注解

此属性是 的 OdbcErrorCollection包装器。

适用于

另请参阅