Filter records in DataSet

  • Thread starter Thread starter Raymond Chiu
  • Start date Start date
R

Raymond Chiu

Dear all,

If I have the dataset, What the code should be to filter records in the
dataset by some fields criteria? Is it like a SQL?

Thanks for your help,
 
Raymond said:
Dear all,

If I have the dataset, What the code should be to filter records in the
dataset by some fields criteria? Is it like a SQL?

Thanks for your help,

You can use a DataView to filter a DataTable.

The DefaultView property in the DataTable returns the default DataView
of the table, which by default has an empty filter, i.e. returning all
rows of the DataTable.

Setting the RowFilter property changes the filter. Example:

someDataTable.DefaultView.RowFilter = "City = 'Västerås'"

If you want more than one filter on the same table (or don't want to
change the default filter), you can create new DataView objects.
 
There is a .Select method.


MyDS.MyTable.Select("EmpID=123");
MyDS.MyTable.Select("LastName='John'");

It is NOT as powerful as tsql/sql select. But gives you some basic
functionality.
 
Back
Top