CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005
    Posts
    8

    Exclamation Doubt on ADO.Net

    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
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Doubt on ADO.Net

    Your doubt is is not that of a newbie.. lot of experienced programmers ask that and it just shows that u r very much experienced..

    Now for your doubt.. this is wat MS has to say..
    http://msdn.microsoft.com/library/de...oncurrency.asp

  3. #3
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: Doubt on ADO.Net

    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"
    Auto-numbered field cannot be updated from the client-side. Eventhough this number is generated when creating new DATAROW in the DATATABLE, this value has to be ignored when doing an INSERT (thus, the whole idea of auto-numbered field in the database - database has to assign that number).

    Even if you don't set the EmployeeID as auto-numbered, you probably will set it as PRIMARY KEY. Therefore, when the last user inserts new record w/ EmployeeID = 100, it will throw an exception. So, it is up to you as the programmer to handle this exception gracefully.

    Can anybody explain me what exactly hapens in database whn both of the statements executed?..
    Well, the first user that executes the update/insert command will save all the changes in the database. The last user on the other hand will probably get some kind of error. Again, it is up to you as a programmer to make sure to handle data integration. For example, when doing an update, check how many records are you updating and then check back how many were actually updated.

    Why is this better? Well, actually it is only better to the user but unfortunately really sucks for the programmer. But then, we program for the user, are we not?

    So, with the disconnected model, data integration must be handled by the programmer(s) instead of the database (most of them).
    Good Luck,
    -Cool Bizs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured