Chapter 12 -- Detecting and Handling Conflicts

[Previous] [Next]

Chapter 12

As you know, multiple users often want to change the same data in your database at the same time. If users would simply agree not to do this, developing multiuser database applications would be much easier. Of course, you can prevent users from changing the same data at the same time by utilizing pessimistic locking in your database, but that's overly restrictive in comparison to optimistic locking. Besides, pessimistic locking is for lazy programmers.

So rather than take the easy way out and write an application that's too restrictive, you choose optimistic locking. You decide to start working with a small application that simulates multiple users trying to update a single record, and you encounter the following error message when the second user tries to perform an update:

 "The specified row could not be located for updating: Some values may have been changed since it was last read." 

You might have had a hunch that the second user's update would fail, but when it did you probably asked yourself, "Now what?"



Programming ADO
Programming MicrosoftВ® ADO.NET 2.0 Core Reference
ISBN: B002ECEFQM
EAN: N/A
Year: 2000
Pages: 131
Authors: David Sceppa

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net