Export (0) Print
Expand All

OleDbEnumerator.GetElements Method

Retrieves a DataTable that contains information about all visible OLE DB providers.

Namespace:  System.Data.OleDb
Assembly:  System.Data (in System.Data.dll)

public DataTable GetElements()

Return Value

Type: System.Data.DataTable
Returns a DataTable that contains information about the visible OLE DB providers.

ExceptionCondition
InvalidCastException

The provider does not support ISourcesRowset.

OleDbException

Exception has occurred in the underlying provider.

The table that is returned by this method contains the following columns, all of which contain strings:

Column Ordinal

Column

Description

0

SOURCES_NAME

The invariant name of the native OLEDB data source or enumerator.

1

SOURCES_PARSENAME

A human-readable name that can be converted to a moniker by using the native COM interface IParseDisplayName. Corresponds to the SOURCES_PARSENAME column returned by the native OLE DB sources rowset.

2

SOURCES_DESCRIPTION

Description of the native OLE DB data source. Corresponds to the SOURCES_DESCRIPTION column returned by the native OLE DB sources rowset.

3

SOURCES_TYPE

One of the following enumeration members: Binder (0), DataSource_MDP (1), DataSource_TDP (2), Enumerator (3). These correspond to the values returned in the SOURCES_TYPE column of the native OLE DB sources rowset.

4

SOURCES_ISPARENT

Applicable to enumerators only. 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. Corresponds to the SOURCES_ISPARENT column of the native OLE DB sources rowset

5

SOURCES_CLSID

A human-readable name, that can be converted to a moniker using the native COM interface IParseDisplayName. Corresponds to the SOURCES_CLSID column returned by the native OLE DB sources rowset.

The following console application retrieves information about all the visible OLE DB providers and displays the information in the console window.

using System;
using System.Data;
using System.Data.OleDb;

class Program
{
 static void Main()
 {
   OleDbEnumerator enumerator = new OleDbEnumerator();
   DataTable table = enumerator.GetElements();

   DisplayData(table);

   Console.WriteLine("Press any key to continue.");
   Console.ReadKey();
 }

 static void DisplayData(DataTable table)
 {
   foreach (DataRow row in table.Rows)
   {
     foreach (DataColumn col in table.Columns)
     {
       Console.WriteLine("{0} = {1}", col.ColumnName, row[col]);
     }
     Console.WriteLine("==================================");
   }
 }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft