Export (0) Print
Expand All

Enumerating Installed Data Providers 

.NET Framework 2.0

Each installed data provider that supports a factory-based class registers configuration information in the machine.config file on the local computer in the DbProviderFactories section. The following configuration file fragment shows the syntax and format for System.Data.SqlClient.

    <add name="SqlClient Data Provider"
     description=".Net Framework Data Provider for SqlServer" 
     type="System.Data.SqlClient.SqlClientFactory, System.Data, 
     Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"

Retrieving Provider Information

You can retrieve information about all of the data providers installed on the local computer by using the GetFactoryClasses method. It returns a DataTable named DbProviderFactories that contains the columns described in the following table.

Column ordinal Column name Example output Description



SqlClient Data Provider

Readable name for the data provider



.Net Framework Data Provider for SqlServer

Readable description of the data provider




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



System.Data.SqlClient.SqlClientFactory, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089

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

This DataTable can be used to enable a user to select a DataRow at run time. The selected DataRow can then be passed to the GetFactory method to create a strongly typed DbProviderFactory. For more information on creating factories, see Working with Factories.

GetFactoryClasses Example

This example demonstrates how to use the GetFactoryClasses method to return a DataTable containing information about the installed providers. The code iterates through each row in the DataTable, displaying information for each installed provider in the console window.

' This example assumes a reference to System.Data.Common.
Private Shared Function GetProviderFactoryClasses() As DataTable

    ' Retrieve the installed providers and factories.
    Dim table As DataTable = DbProviderFactories.GetFactoryClasses()

    ' Display each row and column value.
    Dim row As DataRow
    Dim column As DataColumn
    For Each row In table.Rows
        For Each column In table.Columns

    Return table
End Function

See Also

Community Additions

© 2015 Microsoft