开发者

how to get some rows from dataset using sql sentence?

开发者 https://www.devze.com 2023-02-28 08:24 出处:网络
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

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

精彩评论

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

关注公众号