I need to check whether a DataTable consists of any null Values?
Expected Result: Boolean Value (True or False)
DataTable : We Know only the Name of the DataTable, Say “DT”, NOT Sure How many Columns and NOT Sure How Many rows it has.
Logic to Use : Without Using Loop.
I just wanted to know whether we have any Null Value inside that DataTable or Not.
But I’m not exactly looking for this.
As I specified the requirement : We Know only the Name of the DataTable, Say “DT”, NOT Sure How many Columns and NOT Sure How Many rows and NOT Sure the Names of those Columns. DT is a Dynamic DataTable which will be created according to the Scenario.
Please try this:
“dt1.AsEnumerable().Where(Function(row) row.ItemArray.Any(Function(v) TypeOf v Is DBNull)).ToList().Count()”
Replace dt1 with your datatable. Basically this will return the number rows has null values
Use if condition and see if count is greater than 0 then it has null value.