利用DataSet、DataTable、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";
}
利用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);