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


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


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.


Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.