Mauricio - 8 months ago 149
C# Question

# "Microsoft.ACE.OLEDB.12.0” not recognized in Windows 10

Background

I'm developing a Windows Form application which connects to a Microsoft Access database.

This is a sample code that I use in the development:

``````try
{
string AccessFilePath = @"\.myDataBase.mdb"; // Path of the Access database.
string sqlStatement = "SELECT * FROM myTable WHERE IdTable = 5;";
string connstr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + AccessFilePath;
OleDbConnection conn = new OleDbConnection(connstr);
OleDbCommand cmd = new OleDbCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = sqlStatement;
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
catch (Exception ex)
{
MessageBox("Error: " + ex.Message);
}
``````

The following list describes the environment of my development:

• Visual Studio 2015 Community

• Solution created in Framework .NET 4.0

• Operating system: Windows 10 Pro - 64 bits.

• This development must work on Windows XP, Windows 7 and upper versions.

Issues

In my PC which has Windows 10 Pro OS, I search in the C:/ Hard Disk and I found that ACEOLEDB.DLL is already installed in the following locations:

This is before install the Data Connectivity Components:

``````- C:\Program Files (x86)\Microsoft Office\root\VFS\ProgramFilesCommonX86\Microsoft Shared\OFFICE16
- C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE15
- C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14
``````

Click to enlarge the image:

When I installed the Data Connectivity Components in my PC, the ACEOLEDB.DLL is located at:

``````- C:\Program Files (x86)\Microsoft Office\root\VFS\ProgramFilesCommonX86\Microsoft Shared
``````

I really don't know why even after install Data Connectivity Components I'm still getting this error:

"The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine"

Questions

• How Data Connectivity Components are handled by the OS?

• How can validate correctly if OS has the Data Connectivity Components installed?

After change the Platform Target to x86 as user LarsTech suggested in his comment, in the end user machines which has Windows 7 OS and no Office suite installed. It worked correctly.

I though that this change would be enough, but, for some unknown reason, in my PC, that wasn't.

So, I have to research again and I found a similar problem here.

The workaround in this particular situation is install:

Microsoft Access 2010 Runtime

In my case, the following ACEOLEDB.DLL entries were created:

``````- C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE12
- C:\Windows\Installer\\$PatchCache\$\Managed\00004109C10000000000000000F01FEC\14.0.4763
``````

I think that the last entry was created by the 2010 Runtime installation.