简体   繁体   中英

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

I am simply trying to connect to an MS Access database which is on my local computer.

I am using Visual Studio 2022, my system is 64-bit, my MS Office is also 64-bit. I have the "Database Engine 2016 Redistributable-x64" installed on my computer.

If I connect to the database manually clicking under Tools tab: "Connect to Database" it is working and connects, however if I try to code it, it fails:

OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=testapp.accdb");
        private void button1_Click(object sender, EventArgs e)
        {
            OleDbCommand cmd = con.CreateCommand();
            con.Open();

Thanks in advance for anyone helping me out here!

The simple solution is to change the active solution platform from AnyCPU to x64 under Debug in the Configuration Manager.

Alternatively, I had it running while set as AnyCPU , by installing the Access Database Engine 2016 (32-bit) on top of the 64-bit version as a quiet or passive installation.

Thanks everyone for helping.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM