By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,269 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

Filter records in DataSet

P: n/a
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,
Jul 30 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Raymond Chiu wrote:
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.

--
Göran Andersson
_____
http://www.guffa.com
Jul 30 '08 #2

P: n/a

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.
"Raymond Chiu" <rc******@yahoo.com.hkwrote in message
news:OW**************@TK2MSFTNGP06.phx.gbl...
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,

Jul 30 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.