Problems with the excel connection string

2

I have the following code snippet that connects to Excel, however it 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 Microsoft Access Database Engine 2010 Redistributable file that was meant to fix this error and even though it contained this exception .

    
asked by anonymous 03.10.2017 / 22:18

1 answer

2

In 64-bit Windows Office environments (2010, 2013), there are many reports of this error. The workaround or workaround is a little 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 most people.

Source: link

    
03.10.2017 / 22:22