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();
}