Export (0) Print
Expand All

Enumerating Installed Data Providers 

By using the GetFactoryClasses method, you can enumerate data providers that are installed on your computer. These data providers are listed in the machine.config file.

The results are returned as a DataTable named DbProviderFactories that contains these columns:

Column ordinal Column name Example output Description

0

Name

Odbc Data Provider

Readable name for the data provider

1

Description

.Net Framework Data Provider for Odbc

Readable description of the data provider

2

InvariantName

System.Data.Odbc

Name that can be used programmatically to refer to the data provider

3

AssemblyQualifiedName

System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Fully-qualified name of the factory class, which contains enough information to instantiate the object.

The following example enumerates data providers that are installed on the local computer.

using System;
using System.Data;
using System.Data.Common;

class Program
{
  static void Main()
  {
    DataTable providerTable = DbProviderFactories.GetFactoryClasses();

    // Enumerate the available providers:
    foreach (DataRow row in providerTable.Rows)
    {
      foreach (DataColumn col in providerTable.Columns)
      {
        Console.WriteLine("{0}: {1}", col.ColumnName, row[col.ColumnName]);
      }
    }

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

See Also

Show:
© 2014 Microsoft