Updating Databases
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=19643
Printed Date: 29 March 2026 at 10:03am Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Updating Databases
Posted By: ewookie
Subject: Updating Databases
Date Posted: 01 May 2006 at 8:32am
i'm very new to asp and databases too. i was following along with the asp/database tutorial here: http://www.webwiz.net/asp/tutorials/updating_data_from_database.asp
i found myself wondering what would happen if two people were trying to update the same record at the same time. i know there is some locking going on in the example code, i'm just not sure what it's locking. can someone identify which parts of the code (if any) would prevent two people from trying to update the same record at the same time?
to be sure i'm making myself clear, here is the scenario i'd like to avoid: user1 opens record1 for updating and begins editing. while user1 is editing, user2 opens record1 and begins editing. while user2 is editing, user1 submits his/her changes. the database is updated with user1's changes and user1 walks away happy. then user2 submits his/her changes and the update is successful. user2 walks away happy. latter in the day, user1 re-examines record1 and finds that the information he/she submitted is not there. user1 schedules an appointment with his/her shrink because he/she thinks he/she is losing his/her mind :)
is there some way to prevent user2 from opening record1 when user1 has it opened? tia
|
Replies:
Posted By: michael
Date Posted: 01 May 2006 at 2:10pm
The locking is done by the database engine usually. In case of Access the OS itself can use Opportunistic Locking as well to enforce record locks. So on the database side, the lock pertains for a couple mili-seconds only. The problem is that editing e.g. an article, it may be opened for a few minutes while user2 opens it etc... the only way to circumvent that, is to implement some kind of checkout functionality. add an extra database field called checkedout or so and tick it when someone opens the record....
------------- http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker
|
Posted By: ewookie
Date Posted: 03 May 2006 at 5:39am
Thank you very much for your explanation and suggestion. I really do appreciate it.
|
|