OleDbEnumerator.GetRootEnumerator 方法
定义
无需 OleDbDataReader 类的实例,即可返回一个 OleDbEnumerator,该读取器包含当前安装的 OLE DB 提供程序的信息。Returns an OleDbDataReader that contains information about the currently installed OLE DB providers, without requiring an instance of the OleDbEnumerator class.
public:
static System::Data::OleDb::OleDbDataReader ^ GetRootEnumerator();
public static System.Data.OleDb.OleDbDataReader GetRootEnumerator ();
static member GetRootEnumerator : unit -> System.Data.OleDb.OleDbDataReader
Public Shared Function GetRootEnumerator () As OleDbDataReader
返回
一个 OleDbDataReader,其中包含可见 OLE DB 提供程序的信息。A OleDbDataReader that contains information about the visible OLE DB providers.
例外
提供程序不支持 ISourcesRowset。The provider does not support ISourcesRowset.
基础提供程序中发生了异常。Exception has occurred in the underlying provider.
示例
以下控制台应用程序检索所有可见的 OLE DB 提供程序的相关信息,并在控制台窗口中显示信息。The following console application retrieves information about all the visible OLE DB providers and displays the information in the console window.
Imports System.Data
Imports System.Data.OleDb
Module Module1
Sub Main()
Dim enumerator As New OleDbEnumerator
Dim reader As OleDbDataReader = OleDbEnumerator.GetRootEnumerator()
DisplayData(reader)
Console.WriteLine("Press any key to continue.")
Console.ReadKey()
End Sub
Private Sub DisplayData(ByVal reader As OleDbDataReader)
While reader.Read()
For i As Integer = 0 To reader.FieldCount - 1
Console.WriteLine("{0} = {1}", _
reader.GetName(i), reader.GetValue(i))
Next
Console.WriteLine("==================================")
End While
End Sub
End Module
using System;
using System.Data;
using System.Data.OleDb;
class Program
{
static void Main()
{
OleDbDataReader reader = OleDbEnumerator.GetRootEnumerator();
DisplayData(reader);
Console.WriteLine("Press any key to continue.");
Console.ReadKey();
}
static void DisplayData(OleDbDataReader reader)
{
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
Console.WriteLine("{0} = {1}",
reader.GetName(i), reader.GetValue(i));
}
Console.WriteLine("==================================");
}
}
}
注解
此方法返回的读取器包含以下列,这些列都包含字符串:The reader returned by this method contains the following columns, all of which contain strings:
| 列序号Column Ordinal | 列Column | 说明Description |
|---|---|---|
| 00 | SOURCES_NAMESOURCES_NAME | 本机 OLEDB 数据源或枚举器的固定名称。The invariant name of the native OLEDB data source or enumerator. |
| 11 | SOURCES_PARSENAMESOURCES_PARSENAME | 可使用本机 COM 接口 IParseDisplayName 转换为名字对象的用户可读名称。A human-readable name that can be converted to a moniker using the native COM interface IParseDisplayName. 对应于本机 OLE DB 源行集返回的 SOURCES_PARSENAME 列。Corresponds to the SOURCES_PARSENAME column returned by the native OLE DB sources rowset. |
| 22 | SOURCES_DESCRIPTIONSOURCES_DESCRIPTION | 本机 OLE DB 数据源的说明。Description of the native OLE DB data source. 对应于本机 OLE DB 源行集返回的 SOURCES_DESCRIPTION 列。Corresponds to the SOURCES_DESCRIPTION column returned by the native OLE DB sources rowset. |
| 33 | SOURCES_TYPESOURCES_TYPE | 以下枚举成员之一:联编 (0) ,DataSource_MDP (1) DataSource_TDP () (,枚举器) 3。One of the following enumeration members: Binder (0), DataSource_MDP (1), DataSource_TDP (2), Enumerator (3). 这些值对应于本机 OLE DB 源行集的 SOURCES_TYPE 列中返回的值。These correspond to the values returned in the SOURCES_TYPE column of the native OLE DB sources rowset. |
| 44 | SOURCES_ISPARENTSOURCES_ISPARENT | 仅适用于枚举数。Applicable to enumerators only. 如果为 true ,则指示该条目适用于在其上调用了 GetSourcesRowset 的同一个枚举器,这意味着它也包含在子枚举中。If true, indicates that the entry applies to the same enumerator on which GetSourcesRowset was called, implying that it is also included in the sub-enumeration. 对应于本机 OLE DB 源行集的 SOURCES_ISPARENT 列Corresponds to the SOURCES_ISPARENT column of the native OLE DB sources rowset |
| 55 | SOURCES_CLSIDSOURCES_CLSID | 可使用本机 COM 接口 IParseDisplayName 转换为名字对象的用户可读名称。A human-readable name, that can be converted to a moniker using the native COM interface IParseDisplayName. 对应于本机 OLE DB 源行集返回的 SOURCES_CLSID 列。Corresponds to the SOURCES_CLSID column returned by the native OLE DB sources rowset. |