This doesn't work
DataTable myNewTable = myDataTable.Select("Name <> 'n/a'").CopyToDataTable();
myDataTable
has a row named Name
. I would like to select the rows from this table where Name is not equal to "n/a". It selects but still am missing the null values i need the null values too.
Can anyone help?
Try this
myDataTable.Select("[Name] is NULL OR [Name] <> 'n/a'" )
Edit: Relevant sources:
Try out Following:
DataRow rows = DataTable.Select("[Name]<>'n/a'")
For Null check in This:
DataRow rows = DataTable.Select("[Name] <> 'n/a' OR [Name] is NULL" )
The way to check for null is to check for it:
DataRow[] myResultSet = myDataTable.Select("[COLUMN NAME] is null");
You can use and
and or
in the Select
statement.
try this:
var result = from r in myDataTable.AsEnumerable()
where r.Field<string>("Name") != "n/a" &&
r.Field<string>("Name") != "" select r;
DataTable dtResult = result.CopyToDataTable();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.