If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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 ???

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