Importing excel into sql server using c# RRS feed

  • Question

  • how to import excel data into sql server using c# in web application
    Tuesday, March 20, 2012 7:48 PM


  • I have a general idea: Read Excel data to a datatable and then save the datatable to the SQL Server database.

     To read Excel data to a datatable in ASP.Net, Here is a similar issue for your reference:


     To save a datatable to SQL Server database, we can easily use SqlBulkCopy.WriteToServer method.

     Here is the document about it for your reference:


     I just have a code  example.


    SqlBulkCopy bulkcopy = new SqlBulkCopy(myConnection); bulkcopy.DestinationTableName = table.TableName;


    And I also would suggest you to try to post it at ASP.Net forum for better support.

    Hope it helps.

    Best Regards,
    Rocky Yue[MSFT]
    MSDN Community Support | Feedback to us

    • Proposed as answer by FUCK QHRBanned Tuesday, March 27, 2012 1:41 AM
    • Marked as answer by Lie You Tuesday, March 27, 2012 2:58 AM
    Thursday, March 22, 2012 3:40 AM