ADo.Net Concurrency doubt


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: ADo.Net Concurrency doubt

  1. #1
    Join Date
    Jun 2005
    Posts
    17

    ADo.Net Concurrency doubt

    I am a Newbie in dot Net..so am really sorry if you feels that my doubt is too kiddish
    ADO.Net is a disconnected database architecture with Dataset as the core object in its object hierarchy.

    For explaining my doubt, I am taking an example of a table named "Employee" in the database named "Company
    Employee table has an autonumberd primary key column "EmployeeID"

    Consider a networked multiuser environment or Internet itself.

    Suppose Employee table has 10 rows in it. A user named "A" retrieves all of the rows and caches in his client side Dataset.
    He then deleted the 10th row and then started editing some of the columns in the 9th row.
    He then adds 11th row with the primary key "EmployeeID" (lets say 100 as the next autonumber generated. So the new record he created as 100 as the "EmployeeID")

    These changes hasnt yet been physically updated to the database.


    At this same point of time another user named "B" extracted the employee table rows from the database and cached in his client side Dataset.First he deleted the 9th row and started editing the 10th row's data. then
    adds 11th row . Since the above changes hasnt been yet updated to the database, the new row created by B also has 100 as the primary key(autonumber)..


    { Even if the primary key is not auto number, let me say that incidently both of them gave 100 as the primary key value for the new rows they created }

    Now from this moment..let me say.. first the user B calls the Dataset.Update method and after tht User B calls the Dataset.Update method.

    Can anybody explain me what exactly hapens in database whn both of the statements executed?..

    Is it that all the valuable data which A has edited in 9th row has gone ??..so as B has edited the 10th row???.. wil it be an
    incosistent database?..Then what abt the new row both has added with the same primary key value???


    Can anybody explain me these anamolies please??


    Another doubt is, we can create a sequence in Oracle database. Can i make it available in a dataset ???

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    If the primary key is autonumber, its value is not assigned until the database is physically updated, so you cannot have two rows with duplicate primary keys.

    If user A deletes a row while user B is editing that row, then user B's update will fail with a "key not found" error. In order to prevent situations like this, you must implement some form of record locking. You may find the following article helpful in understanding these issues: http://www.15seconds.com/issue/030604.htm
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center