Updating records in dataset

29-Jan-2015 21:52 by 9 Comments

Updating records in dataset

If you 're not a greek language reader, you can find english only categories and rss feeds for both posts and articles in my blog.Just look for "Posts in English" and "Articles in English" at the lower left corner of this page.

NET, I wrote this piece of code to extend Microsoft’s example of a simple parent-child relationship.

The function Update Data Set can accept as input an array of tables and their corresponding data adapters, perform all requested CRUD operations and return the dataset with rows having 'as expected' row state and version for merging back to client's datasets.

It is important that the data adapters and the data tables will be passed to Update Data Set function with a specific order, because when relations exists in the dataset and in database, the CRUD operations must be applied in the correct order.

The order expected here is from the children to parent tables.

For example, when we have two tables, Parent Table and Child Table, the data Tables array must contain then in this order Child Table, Parent Table with the same order for their data adapters in data Adapters array.

The philosophy behind the code is this: When the data adapters in the DAL do an update on dataset, they force an Accept Changes on all rows of all tables.

When a row was inserted in the dataset from the client side, the dataset detects identity columns an assign them virtual identity values.

These values usually are identical with the actual identity that the database will assign, except two cases: So, when the data adapters finish updating the tables, they return to the client a dataset with "Un Changed" status and different IDs from what the client's dataset currently holds.

The result is duplicate rows in the client's dataset with row state "Un Changed", with some of them not really exist in database. And indeed, if you access the database directly from the client and your performance needs does not require using the Get Changes method, the data adapters will correctly update your dataset to reflect the actual database data.

But when Get Changes is necessary to reduce your bandwidth consumption, you have a problem.

Error Handling In order to manually process the row states and versions of rows while the data adapters are updating them, we use the Row Updated event of each data adapter.

Microsoft's example starts with direct examination of the Statement Type of each event (to see what the actual action on the row was).

  1. i give up on dating 22-Mar-2015 17:14

    Rhythm Since bebop was meant to be listened to, not danced to, it could use faster tempos.

  2. Sex chats rooms 30-Apr-2016 01:16

    Our customers are young single professionals in their 20s, 30s, and early 40s.

  3. Sexi chat cameri veb 08-Jul-2016 01:22

    We are getting married Sept 8 2012, and I am so excited!