2

I wrote a console application to read the xlsx file in C# using OleDbConnection. It throws the following error

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

Below is the code i have written

string connString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\Suganya\ColumnReport.xlsx;Extended Properties=Excel 12.0;";
OleDbConnection objConn = new OleDbConnection();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
objConn = new OleDbConnection(connString);

string Query = "SELECT * FROM [Sheet1$]";
OleDbCommand objCmd = new OleDbCommand(Query, objConn);

DataTable Table = new DataTable();
dataAdapter.SelectCommand = objCmd;
dataAdapter.Fill(Table);

I have already performed following things to fix the issue.

  1. I have installed AccessDatabaseEngine.exe (32 bit) and found that ACEOLEDB.dll is present in the following path C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14

  2. Tried referring the ACEOLEDB.dll in the application. But it gave me the following error

    A reference to 'ACEOLEDB.DLL' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component

  3. The configuration platform of console application is of 32 Bit

Environment Details

  1. Windows Server 2008 (64 bit)
  2. Visual Studio 2010 ( 32 bit)
  3. MS office is not installed

Checked the following links to fix the issue

1.http://www.codeproject.com/Questions/486549/Theplus-27Microsoft-ACE-Oledb-12-0-27plusproviderp 2.http://www.codeproject.com/Questions/337953/The-Microsoft-ACE-OLEDB-12-0-provider-is-not-regis

Any help is highly appreciated.

Prix
  • 19,417
  • 15
  • 73
  • 132
user2743117
  • 21
  • 1
  • 2

1 Answers1

0

You have to install Microsoft Office; Office installation process will copy and register the wished assemblies ('ACEOLEDB.DLL') in the GAC, or you can add the missing assemblies in your bin (application) directory or regsiter them by your self.

Bassam Alugili
  • 16,345
  • 7
  • 52
  • 70
  • Won't installed the 2007 Office System Driver: Data Connectivity Components work? http://www.microsoft.com/en-us/download/details.aspx?id=23734 Answer from here: http://stackoverflow.com/a/3971925/2258 – Richard Morgan Sep 03 '13 at 14:02
  • You can use the redistributable Interop Assemblies from Microsoft this included your wished dlls. http://www.microsoft.com/en-us/download/details.aspx?id=3508 – Bassam Alugili Sep 04 '13 at 07:01
  • Is "Microsoft.ACE.OLEDB.12.0" part of that redistributable Interop Assemblies? I still get the unregistered provider error after adding Office.Interop.Excel to my project references. – spikey Oct 22 '19 at 12:00