1
votes

I got this exception: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

I was trying to connect Excel 2010 files with OleDBConnection. I have windows 7 64bit and office 2010 32 bit.

I have tried to install Microsoft Access Database Engine 2010 Redistributable which suggested from: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered in the local machine

I also tried this suggestion: http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/1d5c04c7-157f-4955-a14b-41d912d50a64

Neither one of them works for me. Anyone help?

Here is my code: string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=d:\Sample.xlsx;Mode=Share Deny Write;Extended Properties=\"HDR=YES;\";Jet OLEDB:Engine Type=37";

OleDbConnection connection = new OleDbConnection(connectionString);

try
{
    connection.Open();

    OleDbCommand command = new OleDbCommand("SELECT * FROM [Sheet1$]", connection);
    OleDbDataAdapter adapter = new OleDbDataAdapter();
    adapter.SelectCommand = command;

    DataSet ds = new DataSet();
    adapter.Fill(ds);

    ds.Tables[0].Rows.Count.Dump();

}
catch (Exception)
{            
    throw;
}
finally
{
    connection.Close();
}
1

1 Answers

0
votes

Here's a discussion about this error, please refer to it and let me know whether it is worked for you.

HOW TO FIX

Best Regards

try installing this first: http://www.microsoft.com/download/en/details.aspx?id=13255

try the following method:

NOTE: this DOES work for office 2010 even though it is for 2007 office

  1. download and install this: Download here

  2. in VS click add data source, follow the wizard.