Wednesday, April 27, 2011

C#: The Microsoft.ACE.OLEDB.14.0 provider is not registered on the local machine

I need to create an application which reads data from a excel file in 64 bit environment and an driver is needed.

Microsoft Access database Engine 2010 Redistributable

After I install the 64bit version, I run the following code to create a connection to an excel file

String connectionString = "Provider=Microsoft.ACE.OLEDB.14.0;" +
                                    "Data Source=" + "C:\\Downloads\\haha.xls;" +
                                    "Extended Properties=Excel 8.0;HDR=YES;";
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
When I runs the above code,  conn.Open() throws an InvalidOperationException was unhandled by user code. The exception shows "The Microsoft.ACE.OLEDB.14.0" provider is not registered on the local machine.


In order to solved this problem, I create a new VM and install the AccessdatabaseEngine.exe in a 64 bit environment. After that, the above code runs fine.

No comments:

Post a Comment