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.
I have installed
AccessDatabaseEngine.exe
(32 bit) and found thatACEOLEDB.dll
is present in the following pathC:\Program Files (x86)\Common Files\microsoft shared\OFFICE14
Tried referring the
ACEOLEDB.dll
in the application. But it gave me the following errorA 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
The configuration platform of console application is of 32 Bit
Environment Details
- Windows Server 2008 (64 bit)
- Visual Studio 2010 ( 32 bit)
- 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.
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.