Click to See Complete Forum and Search --> : Prevent 2 users from editing same record thru asp app
Nagash
April 28th, 2004, 04:35 PM
--------------------------------------------------------------------------------
Is there a way(Iread this long time ago in 4guys but cant find the article) That when lets say 2 users log in to my web app and they try to say edit the same record to prevent this from happening. So lets say UserA get to the record first. I want to prevent Userb from getting to that record and editing it at the same time.
Can anyone point me in the right direction?
damonsiusta
May 3rd, 2004, 04:01 AM
Hi,
One way I know of is when the user starts to edit the record, before you return the data in the recordset update a 'status' field of the record in question to 'locked'. Before allowing a user to edit a record you could check this status. If the status is 'locked' allow the user to view the record but not save any changes, otherwise allow changes. Once the record has been saved you can update the status once again to 'Available'. The major drawback to this solution is if the user has chosen to edit a record (Updated the status to 'locked') and the user closes the browser before saving (or navigates away) the record status will remain 'locked' and no one will be able to edit it again (Perhaps some script validation might solve this? i.e. attempt to release the record if the user navigates away). Another solution would be to store the currently edited record IDs (in an array) in the application session object and check if the ID is in there (The same problem however, would apply to this solution as well i.e. navigating away without removing the ID from the application session object).
Hope this helps….
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.