Problems with excel connection string

I have the following snippet of code that makes connection to Excel, but returns me the error:

string sFileXLSX = ConfigurationManager.AppSettings["ExportPerformanceEntrega"];
string strConnXLSX = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + sFileXLSX + "';Extended Properties=Excel 12.0;";

using (OleDbConnection conn = new OleDbConnection(strConnXLSX))
{
    //SQL para fazer o Delete

    string strSQL = "DELETE FROM [Base Entregue1$]";
    //Criando o OleDbCommand com o SQL e a conexão
    OleDbCommand cmd = new OleDbCommand(strSQL, conn);
    //Abrindo a conexão
    conn.Open();
    //Executando o Delete
    cmd.ExecuteNonQuery();
    //Fechando a conexão
    conn.Close();
}

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

But I already installed the file Microsoft Access Database Engine 2010 Redistributable that was to correct this error and still contained returning this exception.

Author: Wictor Chaves, 2017-10-03

1 answers

In Office 64-bit Windows environments (2010, 2013), there are many reports about this error. The solution or workaround is a bit strange, but it seems to work for most people.

The "Microsoft Access Database Engine 2010 Redistributable" installation package seems to be the natural solution, but several reports say it does not work.

Instead, using the "2007 Office System Driver: Data Connectivity Components" seems to solve the problem for the most people.

Source: https://www.connectionstrings.com/the-microsoft-ace-oledb-12-0-provider-is-not-registered-on-the-local-machine/

 2
Author: Lucas Augusto, 2017-10-03 20:22:31