OleDbErrorCollection 类

定义

收集由用于 OLE DB 的 .NET Framework 数据提供程序生成的所有错误。 此类不能被继承。

public ref class OleDbErrorCollection sealed : System::Collections::ICollection
[System.ComponentModel.ListBindable(false)]
public sealed class OleDbErrorCollection : System.Collections.ICollection
[System.ComponentModel.ListBindable(false)]
[System.Serializable]
public sealed class OleDbErrorCollection : System.Collections.ICollection
[<System.ComponentModel.ListBindable(false)>]
type OleDbErrorCollection = class
    interface ICollection
    interface IEnumerable
[<System.ComponentModel.ListBindable(false)>]
[<System.Serializable>]
type OleDbErrorCollection = class
    interface ICollection
    interface IEnumerable
Public NotInheritable Class OleDbErrorCollection
Implements ICollection
继承
OleDbErrorCollection
属性
实现

示例

以下示例显示 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

注解

通过创建 OleDbException 此类来收集类的 OleDbError 实例。 OleDbErrorCollection 始终包含类的至少一个实例 OleDbError

属性

名称 说明
Count

获取集合中的错误数。

Item[Int32]

获取指定索引处的错误。

方法

名称 说明
CopyTo(Array, Int32)

将元素OleDbErrorCollection复制到从指定索引处开始的Array元素Array

CopyTo(OleDbError[], Int32)

将当前 OleDbErrorCollection 的所有元素复制到指定目标索引处的指定 OleDbErrorCollection 元素。

Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetEnumerator()

公开 GetEnumerator() 方法,该方法支持由 .NET Framework 数据提供程序对集合进行简单迭代。

GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

显式接口实现

名称 说明
ICollection.IsSynchronized

有关此成员的说明,请参阅 IsSynchronized

ICollection.SyncRoot

有关此成员的说明,请参阅 SyncRoot

扩展方法

名称 说明
AsParallel(IEnumerable)

启用查询的并行化。

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryable

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定类型。

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。

适用于

另请参阅