Identifying Added / Modified / Deleted rows in Datasets.

Identifying Added / Modified / Deleted rows in Datasets. There are two ways of identifying the dataset modifications. 1. By using Getchanges method.This method gets all the rows that

DevPro Staff

July 4, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today

Identifying Added / Modified / Deleted rows in Datasets. There are two ways of identifying the dataset modifications.

1. By using Getchanges method.

This method gets all the rows that are affected and this method is at dataset level.
The simple syntax of using this is,
DataSet  DS = dataset1.GetChanges()

GetChanges method is overloaded to accept parameters. These parameters are nothing but

rowstates. Based on the row state mentioned, the resultant dataset contains these

modifications.

ex : DataSet DS = dataset2.GetChanges(DataRowState.Added)
This overloaded method comes good incases where we need to validate the newly added

rows against business rules.

The same technique can be used to identify the other rows that are modified or

deleted.

2. By using DataView.
Using dataview, we can get datarows that are modified are added using RowStateFilter.
We can apply RowStatefilter for deleted rows.

 

But in any case,if we try to access the deletedrow we will get a runtime exception.

The best use of it is when we need to fire indepent update commands for insert, update and delete, we can use the reusulatant datasets instead of cumulative one.

 

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like