Getting a List of Installed OLE DB Providers in .NETOctober 12th, 2011 | Posted by in .NET
Recently I was working on a little side project, where I needed to allow users to connect to a variety of data sources using several connection types – SQL Server, OLE DB and ODBC. Unless I wanted users to manually type in the OLE DB provider (errr… I had no intention of even doing this myself…) then I needed to populate a list of installed OLE DB providers on the current machine.
Having had very little experience in .NET programming I searched around a bit and found a few less the elegant solutions, but was surprised just how simple it was to do in the end. In fact there’s a class to do it… OleDbEnumerator
There’s a couple of methods of interest in the class – GetElements() which returns a data table containing information about the installed OLE DB providers, and GetRootEnumerator() which returns a data reader with information about the installed OLE DB providers.
In a windows forms application, populating a data grid view is as simple as one line:
' Set the data source of the data grid view to the
' data table returned by GetElements()
DataGridView1.DataSource = New OleDbEnumerator().GetElements()
The resulting data grid view is shown below.