Click here to Skip to main content
15,886,813 members
Please Sign up or sign in to vote.
1.00/5 (1 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

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!
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900