Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Updating Databases
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Updating Databases

 Post Reply Post Reply
Author
ewookie View Drop Down
Newbie
Newbie


Joined: 01 May 2006
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote ewookie Quote  Post ReplyReply Direct Link To This Post Topic: Updating Databases
    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
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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....
Back to Top
ewookie View Drop Down
Newbie
Newbie


Joined: 01 May 2006
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote ewookie Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2006 at 5:39am
Thank you very much for your explanation and suggestion.  I really do appreciate it.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.