0

I try to link my access database with visual Studio but I always receive this error. I installed Access database engine 2010 and 2016 but it doesn't change anything. I also tried to build my C# application with both CPU (x86 and x64) but I still receive the same error.

Red hood
  • 29
  • 1
  • 1
  • 7
  • You need a special parameter when installing the right model. Do a google search.. – TaW Feb 15 '20 at 21:19
  • 1
    Does this answer your question? [The Microsoft.ACE.OLEDB.12.0 provider is not registered on the local machine even if it actually IS installed](https://stackoverflow.com/questions/55730122/the-microsoft-ace-oledb-12-0-provider-is-not-registered-on-the-local-machine-eve) – Rene Feb 15 '20 at 21:32

2 Answers2

1

If you build as x86, then having installed Access 2010 this should work.

I have a tiny ready to go .exe file here:

There are both a x86, and a x64 bit version in the zip file. Unzip, run and browse to a accDB or mdb file. If you can open and browse to a accDB file, then .net is working and you have the ACE database engine installed.

You did not post your code (just post the connection string part).

You also do NOT mention if you are using the .net oleDB provider, or the .net ODBC provider. And of course you cannot use the sqlprovider.

So, we need more information then my car is broken. We are quite much shooting in the dark here and making wild guesses. We don't know what you attempted. We don't know if you using JET or ACE. We don't know if you are using the ODBC provider, or the oleDB one. We don't know what you code looks like so far.

If you using oleDB, then .net code as vb.net will look like this:

Dim strCon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\test\testdb.accdb"
Dim mycon As New OleDb.OleDbConnection(strCon)
Dim dataRead As New OleDb.OleDbDataAdapter("select * from tblCustomers", mycon)
Dim rst As New DataTable
dataRead.Fill(rst)

Or as c#, it will look somthing like this:

string strCon = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\test\testdb.accdb";
OleDb.OleDbConnection mycon = new OleDb.OleDbConnection(strCon);
OleDb.OleDbDataAdapter dataRead = new OleDb.OleDbDataAdapter("select * from tblCustomers", mycon);
DataTable rst = new DataTable();
dataRead.Fill(rst);

As noted, if you want to test/try that JET or ace is working, then you can download this already working sample here:

Just unzip and run both the x64 example, and the x86 example. If neither work, then you don't have the Access database engine installed, or it not exposed for your use:

https://1drv.ms/u/s!Avrwal_LV4qxhpdA1Z2344l9CnhwyQ?e=QeTPrs

Albert D. Kallal
  • 42,205
  • 3
  • 34
  • 51
1

You need to use net framework and not net core

I picked netcore when I was creating the project and that was the issue.

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
  • You can use .NET Core/.NET 5. I had to set the build architecture to x86 explicitly (Properties -> Build -> Platform target: x86). Until I did that it would just throw an exception saying 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. – jspinella Aug 16 '21 at 18:57
  • Obviously you want to set platform target/bitness to 64-bit if you are running 64-bit Office/the 64-bit version of the ACE driver. Should be fun when VS 2022 comes out running in 64-bit. I wouldn't surprised if we needed to move to 64-bit Office when 64-bit VS comes out. – jspinella Aug 16 '21 at 18:59