Home / Programming / Blog article: Find All Data Providers Installed On A Machine

| RSS

Find All Data Providers Installed On A Machine

July 29th, 2010 | 2 Comments | Posted in Programming

This post shows you how to find Data Providers installed on a machine. Data providers in .NET Framework provide the plumbing necessary to connect to databases. There are different data providers available which can connect to SQL Server, Oracle or other databases through OleDb. You can find the data providers installed on your machine by looking at Machine.config file. In particular you will be looking for DbProviderFactories element under System.Data. In the screenshot below you can see data providers installed on my machine.

image

A list of data providers can also be retrieved by code. This sample shows you how to retrieve a list of data providers in code.

DataTable dataProviders = DbProviderFactories.GetFactoryClasses();

foreach (DataRow provider in dataProviders.Rows)
{
  Console.WriteLine(provider[0].ToString());
}  

In the code above I am displaying the name of provider. Here is my output.

image

Leave a Reply 551 views, 3 so far today |
Follow Discussion

2 Responses to “Find All Data Providers Installed On A Machine”

  1. Ravikanth Says:

    You can do the same thing in PowerShell by running this one-liner

    [System.Data.Common.DbProviderFactories]::GetFactoryClasses() | % { $_.Name }

  2. Deepak Says:

    Thanks Ravikanth,

    Truly powerful :)

Leave a Reply





Switch to our mobile site