locked
OLEDB Connection String Fails RRS feed

  • Question

  • User-1725652363 posted

    I use OLEDB to read excel file, I have an Excel file with macro (.xlsm) for that I used this connector:

    string connexion_string = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + file + ";Extended Properties=\"Excel 12.0 Macro;HDR=YES;IMEX=1;\"";
    
     try
                {
                    OleDbConnection connexion = new OleDbConnection(connexion_string);
                    connexion.Open();
                    return connexion;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Erreur: " + e);
                    return null;
                }

    but I get this error:

    Échec de IErrorInfo.GetDescription avec E_FAIL(0x80004005).

    and return null

    any solution please?

    Thanks

    Wednesday, June 27, 2018 12:23 PM

Answers

All replies

  • User753101303 posted

    Hi,

    It seems OleDb can't even, retrieve an actual error message. The file does exists, is not password protected, is not blocked by an antivirus software ? I would perhaps try with a dead simple XLSX file to see what happens. If ok, I would add a macro and save to XLSM to see once again what happens with this simple file.

    I'm trying to understand if this is a problem on the web server side or if the problem could be caused by this particular XLSM file.

    Edit: try maybe to drop the final ; in case the connection string parser would expect then Something following this final separator ???

    Wednesday, June 27, 2018 1:54 PM
  • User36583972 posted


    Hi Kati Ais,

    Which section of the code causes this error? Please debug step by step.

    You can refer the following thread's solution: putting [] around the reserved word in the select statement.

    Error: IErrorInfo.GetDescription failed with E_FAIL(0x80004005):
    https://forums.asp.net/t/1225443.aspx?Error+IErrorInfo+GetDescription+failed+with+E_FAIL+0x80004005+

    Please refer to PatriceSc's suggestion to share more details.

    Read and Write Excel Documents Using OLEDB:
    https://www.codeproject.com/tips/705470/read-and-write-excel-documents-using-oledb


    Best Regards,

    Yong Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 28, 2018 6:56 AM