Search code examples
c#oledb

OLEDB Providers not found


I'm getting the error:

System.InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

I have a 64bit system with a 64bit application that have Office 2010 32bit installed. How can my 64bit application access OLEDB?

How can I list the available providers on the system?


Solution

  • How can my 64bit application access OLEDB?

    "Microsoft.ACE.OLEDB.12.0", that is, the Microsoft Access Database Engine 2010 Redistributable can be downloaded from here. There is a 64-bit version, too.

    Connection strings for the "Microsoft.ACE.OLEDB.12.0" provider can be found here.

    How can I list the available providers on the system?

    Use OleDbEnumerator.GetRootEnumerator:

    using System;
    using System.Data;
    using System.Data.OleDb;
    
    class Program
    {
     static void Main()
     {
       OleDbDataReader reader = OleDbEnumerator.GetRootEnumerator();
    
       DisplayData(reader);
    
       Console.WriteLine("Press any key to continue.");
       Console.ReadKey();
     }
    
     static void DisplayData(OleDbDataReader reader)
     {
       while (reader.Read())
       {
         for (int i = 0; i < reader.FieldCount; i++)
         {
           Console.WriteLine("{0} = {1}",
            reader.GetName(i), reader.GetValue(i));
         }
         Console.WriteLine("==================================");
       }
     }
    }