Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
Hi,

I am using asp.net with SQL2008 facing a concurrent user issue, if two users launches the application and clicks save then it is allowing to save the record twice. I need to avoid saving duplicate record. How can I acheive this?

One thing I thought of taking Modifiedat value at the time of launching and comparing this value with database record if it differs then I will display message to the second user. Now the problem is we have migrated records which has same data of modifiedat.

Can any one let us know the best way to handle concurrency issue.
Your help is much appreciated.
-Mani
Posted
Updated 20-Dec-10 7:01am
v2

Two things you can consider:

0) You could lock the record being modified when someone requests the data, and then when a 2nd user requests it while the record is locked, make the edit fields read-only. Put a refresh button on the form and allow the user to re-request the data until he can put a lock on it himself.

1) When the user retrieves the data, save a copy of the data, allow the user to change it, and when he saves it, pass BOTH versions of the data to the database. If his copy of the original data is different than when is currently in the database, prompt him for further action.


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