开发者

how to get some rows from dataset using sql sentence?

i have dataset that contains rows

MyTbl
=====
Name | Age
----------
aa | 23
bb | 90
cc | 2
dd | 1
ee | 14

i need to fill datagrid with all rows that the age > 5

aa | 23
bb | 90
ee | 14
开发者_Python百科

i try this:

dataGrid1.DataSource = Main.dsParts.Tables[1].DefaultView.RowFilter = "Age > 5";

and this:

dataGrid1.DataSource = Main.dsParts.Tables[1].Select("Age > 5");

but it not work !, how to do it ?

thanks in advance


Try this:

Main.dsParts.Tables[1].DefaultView.RowFilter = "Age > 5";
dataGrid1.DataSource = Main.dsParts.Tables[1].DefaultView;

The RowFilter sets the condition, but just setting it doesn't return a new view to display; but from that point on, the .DefaultView will contain only those rows that match that criteria.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜