Reputation: 133
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!
Upvotes: 1
Views: 12505
Reputation: 133
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.
Upvotes: 1