Microsoft.Jet.OLEDB.4.0 provider is not registered on the local machine

Can someone help me with this error? When I try to open a connection with mdb, I get the message “Microsoft.Jet.OLEDB.4.0 error is not registered on the local machine." How can I fix 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());
    }
}
+3
source share
2 answers

This is because there is no Jet driver for 64-bit systems , and I assume that you are trying to run this on an x64-bit OS. You need to compile your program for the target x86. In the project properties on the "Assembly" tab, set the value "Platform" for x86.

+10

64- , Microsoft : Office System 2010, 32-, 64- . Microsoft.Jet.OLEDB.4.0 64- , 64- ( , ).

-, .

2010 - Office System:

Thnks

+5

Source: https://habr.com/ru/post/1722878/


All Articles