How to prevent two user to access same data from sql server


  • i really do not know what would be the best way to prevent two user to access same data from sql server. i have developed a win apps using c# where user click on record to modify it. when user click on records then a new form is shown with data from where user can modify the data. suppose my application is running on two pc and two user open the same record then who update the same data last that will be saved in db.

    so what i did...i create a table and store record id in that table whenever any user open data record.if a record id is stored in table so next time another user can not access that data rather get message who is working on this records. this way my purpose is solved but i do not know whether it is right or best approach or not.

    so guys tell me how to handle this situation with best approach. thanks

    Wednesday, October 30, 2013 8:46 AM


  • I think there are two things,

    1. Concurrent access : Accessing a specific row of a table by multiple users simultaneously. For this refer the appropriate solution in this below link,

    2. Instead of storing a specific record id saperately in a different table, we can also introduce a field "status" in the main table from where you are pulling the information in your application. With this you can pull only those rows in your application whose status are not "completed" say.  I think it will more easier to manage from front end.

    Regards, RSingh

    Wednesday, October 30, 2013 9:03 AM

All replies