Filter records in DataSet

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

Göran Andersson

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

sloan

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top