如何使用DataTable.Select()来选择Null / empty值?

时间:2022-05-24 11:49:53

My data table filled from db is having empty values in some cells.

从db填充的数据表在某些单元格中具有空值。

The results database SP return has Null in them but in DataTable these values are appearing as '' or empty cells.

结果数据库SP返回在它们中有Null但在DataTable中这些值显示为''或空单元格。

Please guide me how to use Select() to select these dbnull/ empty rows.

请指导我如何使用Select()来选择这些dbnull / empty行。

Thanks

2 个解决方案

#1


4  

For one column

一栏

DataRow rows = DataTable.Select("[COLUMN 1]=''");

For more than one column

对于多个专栏

DataRow rows = DataTable.Select("[COLUMN 1]='' OR [COLUMN 2]=''");

#2


61  

The correct way to check for null is to check for it:

检查null的正确方法是检查它:

DataRow[] myResultSet = myDataTable.Select("[COLUMN NAME] is null");

#1


4  

For one column

一栏

DataRow rows = DataTable.Select("[COLUMN 1]=''");

For more than one column

对于多个专栏

DataRow rows = DataTable.Select("[COLUMN 1]='' OR [COLUMN 2]=''");

#2


61  

The correct way to check for null is to check for it:

检查null的正确方法是检查它:

DataRow[] myResultSet = myDataTable.Select("[COLUMN NAME] is null");