title: Reading xlsx file in c# using OleDbConnection throws error
body: <p>I wrote a console application to read the <code>xlsx</code> file in C# using <code>OleDbConnection</code>. It throws the following error</p>
  
  <blockquote>
    <p>The Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.</p>
  </blockquote>
  
  <p>Below is the code i have written</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>I have already performed following things to fix the issue.</p>
  
  <ol>
  <li><p>I have installed <code>AccessDatabaseEngine.exe</code> (32 bit) and found that <code>ACEOLEDB.dll</code> is present in the following path <code>C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14</code></p></li>
  <li><p>Tried referring the <code>ACEOLEDB.dll</code> in the application. But it gave me the following error</p>
  
  <blockquote>
    <p>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</p>
  </blockquote></li>
  <li><p>The configuration platform of console application is of 32 Bit</p></li>
  </ol>
  
  <p>Environment Details</p>
  
  <ol>
  <li>Windows Server 2008 (64 bit)</li>
  <li>Visual Studio 2010 ( 32 bit)</li>
  <li>MS office is not installed</li>
  </ol>
  
  <p>Checked the following links to fix the issue</p>
  
  <p>1.<a href="http://www.codeproject.com/Questions/486549/Theplus-27Microsoft-ACE-Oledb-12-0-27plusproviderp" rel="nofollow">http://www.codeproject.com/Questions/486549/Theplus-27Microsoft-ACE-Oledb-12-0-27plusproviderp</a>
  2.<a href="http://www.codeproject.com/Questions/337953/The-Microsoft-ACE-OLEDB-12-0-provider-is-not-regis" rel="nofollow">http://www.codeproject.com/Questions/337953/The-Microsoft-ACE-OLEDB-12-0-provider-is-not-regis</a></p>
  
  <p>Any help is highly appreciated.</p>