3

Can someone help me with this error? When I try to open a connection to an mdb, I get "The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine" error. How can I correct this?

My code is pretty simple:

class ImportTDB {
    private string filename;
    private string connectionString;

    private int collisions = 0;

    public ImportTDB(String filename) {
        this.filename = filename;
        this.connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename;
    }

    public void loadCustomerList() {
        DataTable dt = new DataTable();
        using (OleDbConnection conn = new OleDbConnection(connectionString)) {
            OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Names", conn);
            conn.Open();
            adapter.Fill(dt);
            conn.Close();
        }

        Console.WriteLine(dt.ToString());
    }
}
Malfist
  • 31,179
  • 61
  • 182
  • 269

2 Answers2

10

That's because there is no Jet driver for 64-bit systems and I suppose you are trying to run this on a x64 bit OS. You need to compile your program to target x86. In the project properties, Build tab, set Platform target to x86.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • There's now a [64-bit version of Jet driver](http://stackoverflow.com/questions/1991643/microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine/1992009#1992009) available. But it also can't help because of [its limitations](http://stackoverflow.com/questions/13854698/how-to-install-visual-studio-2010-setup-project-with-ms-access-database-on-a-com#comment28064050_13854971). – Masood Khaari Sep 25 '13 at 05:41
5

If you are running your application in a 64 bit OS, Microsoft has now released the 2010 Office System Driver Beta: Data Connectivity Components which is supported both in 32 bit as well as 64 bit OS. So using this driver instead of the traditional Microsoft.Jet.OLEDB.4.0 driver will give us a 64 bit application running on a 64 bit server (that is what we really need).

Though this is in beta, it worked fine for me.

You can download this driver from 2010 Office System Driver Beta: Data Connectivity Components

Thnks

neo
  • 6,131
  • 6
  • 22
  • 27