DataView dv = new DataView();
dv.Table = DataSet1.Tables["Suppliers"];
string today=System.DateTime.Now.ToShortDateString();
dv.RowFilter = "birthday = '"+today+"'";DataView dv = new DataView();
dv.Table = DataSet1.Tables["Suppliers"];
string today=System.DateTime.Now.ToShortDateString();
dv.RowFilter = "birthday = '"+today+"'";
利用DataSet过滤数据:
DataSet过滤数据
DataRow[] drUserUrl = dsUserUrl.Tables[0].Select("UserName='北飘'");
DataSet dsUserUrl = new DataSet();
if(drUserUrl.Length>0)
{
dsUserUrl.Merge(drUserUrl);
}
//利用RowState来过滤
DataSet dsTmpUserUrl = dsUserUrl.GetChanges(DataRowState.Unchanged);
DataView的RowFilter与RowStateFilter分别可以按照自定义条件、DataViewRowState的记录行状态来过滤数据(有时测试不太好使,可能因人而异哈哈。。)。
例:
DataView事例
myView.RowFilter = "name<> 'World' and name <> 'Hello' and corpid>400";
for(int t=0;t<myView.Count;t++)
{
TextBox2.Text += myView[t]["name"].ToString()+"\r\n";
}
myView.RowStateFilter=DataViewRowState.Added | DataViewRowState.ModifiedCurrent;
for(int i = 0;i < myView.Count ;i++)
{
TextBox2.Text += myView[i]["name"].ToString()+"\r\n";
}