Click here to Skip to main content
15,890,946 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a csv file from which i have to store data to my table[USERS].
this file is generated daily with some updates to records of user details.
i have done importing part quite well but every time i run this project it INSERTS whole data over again instead of just UPDATE.



say the csv file for day 1 is

1,sushil,sainju,sushil@gmail.com
2,subash,stha,subash@gmail.com
this file is imported to the table quite well but when i run this project after making few updates to the csv file
say
1,sushil,sainju,sushil@gmail.com
2,subash,aaaa,SHAK@hotmail.com

the project will add 2 more records to the table instead of updating the existing records. can anyone pls help me with this?
thanks in advance.:)
Posted

1 solution

Define what makes a line (record) unique, for example the number at the beginning of the line. To make sure that the table only excepts unique numbers define the number field as the primary key of your table.

Then use this number to search for it in the table. If it exists update the record with the information from the file. If it does not exist insert a new record in the table.
 
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