Arun Chandran C Arun Chandran C - 22 days ago 12
SQL Question

C# DataTable.Select() - How do I format the filter criteria to include null?

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?

Answer

Try this

myDataTable.Select("[Name] is NULL OR [Name] <> 'n/a'" )

Edit: Relevant sources: