W
werk
For limiting access to the database to strictly necessary I try to
filter the query by using DataView.
Thw DataSet ds contains three columns (fields) : (LAND_ID, Landcode,
Landnaam) and four rows.
I try to filter out only one country (key is LAND_ID) with the
following code:
DataTable dt = ds.Tables[0]; // ds contains the dataset of the query
4 rows
DataView dv = new DataView(); // create a new Dataview instance
dv.Table = dt; // copy the table into dv
dv.Table.TableName = "hello"; // set an name (optional ???)
dv.AllowDelete = true; // required ??? ( tried also without
this line)
dv.AllowEdit = true; // required ??? ( tried also without
this line)
dv.AllowNew = true; // required ??? ( tried also without
this line)
dv.RowFilter = "LAND_ID = 8"; // Selection filter
dv.RowStateFilter = DataViewRowState.ModifiedCurrent; // required ???
( tried also without this line)
dv.Sort = "LAND_ID"; // sort
After executing this code the dv.Table still contains 4 rows and not
one as it should be.
I tried again with the constructor:
dv = new DataView(dt, "LAND_ID = 8", "LAND_ID",
DataViewRowState.ModifiedCurrent);
with the same (wrong) result.
What did I wrong ?
Thanks Klaas
filter the query by using DataView.
Thw DataSet ds contains three columns (fields) : (LAND_ID, Landcode,
Landnaam) and four rows.
I try to filter out only one country (key is LAND_ID) with the
following code:
DataTable dt = ds.Tables[0]; // ds contains the dataset of the query
4 rows
DataView dv = new DataView(); // create a new Dataview instance
dv.Table = dt; // copy the table into dv
dv.Table.TableName = "hello"; // set an name (optional ???)
dv.AllowDelete = true; // required ??? ( tried also without
this line)
dv.AllowEdit = true; // required ??? ( tried also without
this line)
dv.AllowNew = true; // required ??? ( tried also without
this line)
dv.RowFilter = "LAND_ID = 8"; // Selection filter
dv.RowStateFilter = DataViewRowState.ModifiedCurrent; // required ???
( tried also without this line)
dv.Sort = "LAND_ID"; // sort
After executing this code the dv.Table still contains 4 rows and not
one as it should be.
I tried again with the constructor:
dv = new DataView(dt, "LAND_ID = 8", "LAND_ID",
DataViewRowState.ModifiedCurrent);
with the same (wrong) result.
What did I wrong ?
Thanks Klaas