locked
Copying data from excel to database RRS feed

  • Question

  • User-473868782 posted

    Hello guys,

    I am getting error in copying data from excel to sqlserver database.

    connection sring for excel is

     MyConnection = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; Data Source='" + val + "';Extended Properties=Excel 8.0;");

    thanks!

    Thursday, March 27, 2014 6:19 AM

Answers

  • User-734925760 posted

    Hi,

    According to the error message, I suggest to check if the connectionstring is correct, you can make some break points to the application, then to debug steps by steps to check this point.

    Also please refer to update the connectionstring to the code below:

    string SourceConstr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + val  + "';Extended Properties= 'Excel 8.0;HDR=Yes;IMEX=1'";

    For more information, please refer to the link below:

    http://www.codeproject.com/Tips/300639/Import-Data-from-excel-to-SQL-server-using-Csharp

    Hope it's useful for you.

    Best Regards,

    Michelle Ge

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 28, 2014 3:51 AM

All replies