Home > Asp.net > How to import data from MS Excel

How to import data from MS Excel

This post was most recently updated on August 5th, 2024

If you have data in excel and you want to add data in you database using C# this is useful example. Follow below steps:

Step 1:

Create database tables to import data

Step 2:

Add below namespaces in your project

Step 3:

 Add below method and send file path to this method as parameters.

 This method get file path as parameter then  set connection string and after that delete data from sql table. If you want to delete then comment code for delete record. Then using oledbcommand & bulkinsert insert data into destinationtablename. 

 

This Article is TAGGED in , , , , . BOOKMARK THE permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">