Click here to Skip to main content
15,913,836 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hello Guys,

I have one project of client and client's requirement is that he want to upload data from Excel-sheet to Sql Database using web page in asp.net c#

I know simple how to upload data from Excel-sheet to Sql DB table but Question is that(?) - Suppose 1st time client upload 10 record from 1 sheet to Sql Db and 2nd time client and more 5 record in Excle-Sheet so total record is 15 and then client upload record then I have already 10 old record and this new 15 record upload then total 25 record inserting in Sql Db but I need to upload only last added 5 records only into Sql Db and also client made changes in 1st record then it also be updated in Sql DB.
So how it possible in best way for manage or sync Database

Technology : Asp.net 4.0/4.5, C#, Sql Server


Thanks...

What I have tried:

Hello Guys,

I have do simple upload data from Excel Sheet to Sql Database but every time I upload same Excel sheet data with addition and updation then effect should be done with exist data remain as it is in sql database and all excel data inserting as new entry so I want to as both updation and new addition should be perform.
Posted
Updated 21-Apr-16 4:08am
Comments
Herman<T>.Instance 21-Apr-16 5:56am    
Is Google banned in your country?
JamesGill 21-Apr-16 6:11am    
No So, I can't use this community forum for any technology help
Herman<T>.Instance 21-Apr-16 6:18am    
Have you checked all the given answers on this same question on CodeProject?

 
Share this answer
 
v2
You have a couple of option if the client insist on having records that have already been uploaded in the sheet again.

1) The first is SQL Bulk Copy. I would not recommend this method for your requirements at all. What you could do is wipe out the data that is already upload and just use bulk copy to insert everything as new. The problem with this you can loose relationships with other tables. Again I would not recommend this at all.

2) You can loop through each line of the excel document and check if the row already exist in SQL and if so update the record if not insert the new record.
 
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