Click here to Skip to main content
14,545,828 members
Rate this:
Please Sign up or sign in to vote.
I am developing asp.net MVC 5 application and I have to develop uploading a large excel file and save its data to the Database.

So, now what I have done is, uploading the file and reading it at the back and create a data model list using that file. Ultimately, the file has nearly 1 million records and it takes to very large time to process and insert.

So, I take nearly a week and still was unable to this correctly and fastest way. So can you help me to do that fastest way using c#(MVC5)?

Thanks All.

What I have tried:

I take nearly a week and still was unable to this correctly and fastest way.
Posted
Updated 6-Feb-20 20:42pm
Comments
Maciej Los 7-Feb-20 2:36am
   
It depends on method you are "reading it at the back and create a data model list". Show your code!

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Please, read my comment to the question.
I'd suggest to follow these steps:
1) create OleDbConnection[^] to MS Excel file, execute select command[^] and load data into datatable[^]
2) create SqlConnection[^] and use SqlBulkCopy class[^] to copy data from datatable to MS SQL Server database

That's all!
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100