How to Use Datatable. Select() to Select Null/ Empty Values?
My Data Table Filled from Db Is Having Empty Values in Some Cells. the Results Database Sp Return Has Null in Them but in Datatable These Values Are Appearing...
My data table filled from db is having empty values in some cells.
The results database SP return has Null in them but in DataTable these values are appearing as '' or empty cells.
Please guide me how to use Select() to select these dbnull/ empty rows.
Thanks
2 Answers
The correct way to check for null is to check for it:
DataRow[] myResultSet = myDataTable.Select("[COLUMN NAME] is null");
For one column
DataRow rows = DataTable.Select("[COLUMN 1]=''");
For more than one column
DataRow rows = DataTable.Select("[COLUMN 1]='' OR [COLUMN 2]=''");