Awadhendra
Awadhendra

Reputation: 513

populating data source drivers name in combo box

I want to populate all available data source drivers in c#. Like ODBC driver, .NET Framework data provider etc. As you can see that in crystal report application all available data sources is displayed when you configure connection with your sql server.

Can we check that whether OleDb driver, ADO.NET driver exist or not using c# code.

Upvotes: 2

Views: 547

Answers (1)

jgauffin
jgauffin

Reputation: 101166

The example that MSDN uses to list ADO.NET providers (for ODBC, check the comment by @HarisHasan):

static DataTable GetProviderFactoryClasses()
{
    // Retrieve the installed providers and factories.
    DataTable table = DbProviderFactories.GetFactoryClasses();

    // Display each row and column value.
    foreach (DataRow row in table.Rows)
    {
        foreach (DataColumn column in table.Columns)
        {
            Console.WriteLine(row[column]);
        }
    }
    return table;
}

Upvotes: 1

Related Questions