-2

I'm getting the following error

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

while reading the data from Excel file using OLEDB Data Reader.

Its not working in both 32 and 64 bit machine. Currently my machine having MS office 2013 and VS 2010.

string Connection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\"Excel 12.0;HDR=YES;IMEX=1;MAXSCANROWS=15;READONLY=FALSE\"";

OleDbConnection con = new OleDbConnection(Connection);
OleDbCommand command = new OleDbCommand();
DataSet ds = new DataSet();
command.CommandText = sql;
command.CommandType = CommandType.Text;
command.Connection = con;
command.Connection.Open();
OleDbDataReader dr = command.ExecuteReader(CommandBehavior.CloseConnection);
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
user2960882
  • 57
  • 1
  • 8

2 Answers2

0

You need to change the Solution Platform from "Any CPU" to "x86". The steps are given below:

  1. Right click on the Solution File in Solution Explorer

  2. Click on the Configuration Manager.

  3. Click on the Active Platform Drop down, if x86 is already there then select that, else click on New.

  4. Select x86 from the new platform dropdown:

  5. Compile and run your application.

If you are still facing the issue, then try installing Office System Driver. from follow site

http://www.microsoft.com/en-us/download/details.aspx?id=23734

vakeel
  • 287
  • 2
  • 7
0

Please refer to the following link for a possible solution:

On 64-bit Windows and 64-bit Office (2010, 2013) environments, there are many reports on this error...

...try using 2007 Office System Driver: Data Connectivity Components

Conrad Lotz
  • 8,200
  • 3
  • 23
  • 27