Problems with the excel connection string

Asked

Viewed 169 times

2

I have the following code snippet that connects to Excel, but returns 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

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

1 answer

2


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

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

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

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

  • Agusto Strangely it really worked.

  • What a good guy! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.