Monday, July 11, 2005

Data Concurrency Violations in ADO.NET

Bcoz the DataSet is a disconnected data model, quite often we may have to handle concurrency problems. There are basically 3 ways in which data concurrency is handled:
  • Pessimistic locking-- A range lock is obtained on the required rows and no one else can modify the rows during that time. Fully fool-proof, but reduces the scalibility drastically
  • Optimistic locking -- If there are data changes that has happened in between the user updates, then the user is given the choice to either overwrite the changes or discard his changes.
  • Last wins -- Whoever updates last will overwrite everything.

ADO.NET used Optimistic concurrency and hence it is possible to alert the user of any concurrency violations. An excellent article regarding the same is available here.