Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How can I prevent two users from loading the same database record/row ?
If the first user loads the record to work on it, it will be unavailable to other users unless the first user free it.

Please HELP!
Posted
Comments
Martin Arapovic 21-Feb-12 11:06am    
Hi,
You didn't mentioned what database you use, but I will suppose that you are using SQL Server. First thing that is on my mind is row versioning. You can handle Optimistic Concurrency Exception and that way you can detect that row/record is changed...
Just add one more column (TimeStamp or RowVeriosn data type) in your table and you can test this. If you want more details just google and you will find many articles bout this topic...
Ed Nutting 21-Feb-12 13:46pm    
Or use the System.Data stuff, specifically DataContext class, that will take care of all the concurrency, update issues for you (mostly, by no means all but mostly...) - combined with Linq it's very powerful :)

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