C # DataTable.Select () - how to format filter criteria?
this does not work
DataRow[] mySelectedRows = myDataTable.Select("processed <> True");
myDataTable has a processed string. I would like to select rows from this table where the processed is not True. Can anyone please help?
Bool or string processed?
If bool then "not processed" should work differently if its string is "processed <>" True "- using single quotes as delimiters inside the where string. that you are testing the right thing (this has bitten me in the past).
This should work fine, but it won't return the lines where it processed
is null
.
To enable null, try this:
DataRow[] rows = myDataTable.Select("isnull(processed, false) <> true");
SQL null is undefined. It is not equal to a boolean value true
, but it is also not equal to true. (See Null (SQL) .)
For a link to a generic filter expression, see the DataColumn.Expression
MSDN topic .