So I have this datatable that I filter in which, I will check if it’s empty or not.
I tried making an If with Condition If dt is Nothing OrEsle dt.rows.count = 0
But it will always have one row of empty white space of ''''', so it isn’t empty nor the rows is equal to zero.
I also tried removing the empty rows before the If condition, but it gives an error of Removing Empty Rows: The source contains no DataRows.
I know I can do like if one column is empty. But there are some cases In which some of columns may or may not contain anything. The Process should continue if atleast one cell in any of the columns contains a value.
ExcelData.Rows.Cast(Of DataRow)().Where(Function(row) Not row.ItemArray.All(Function(field) field Is DBNull.Value Or field.Equals(“”))).CopyToDataTable()
This eliminate DBNull and empty space in the entire table collection.
Thanks for replying, I actually use this for removing empty rows as what I mentioned above. Unfortunately, it gives me the Removing Empty Rows: The source contains no DataRows. error
Code doesn’t seem to work. Sorry that I can’t understand what’s was wrong
Error ERROR Validation Error Compiler error(s) encountered processing expression "dt.AsEnumerable.Any(function(row)row.ItemArray.Any(function (col)not string.IsNullOrWhiteSpace(row(col).ToString.Trim)))".
Overload resolution failed because no accessible 'Item' can be called with these arguments:
'Public Default Property Item(column As System.Data.DataColumn) As Object': Option Strict On disallows implicit conversions from 'Object' to 'System.Data.DataColumn'.
'Public Default Property Item(columnName As String) As Object': Option Strict On disallows implicit conversions from 'Object' to 'String'.
'Public Default Property Item(columnIndex As Integer) As Object': Option Strict On disallows implicit conversions from 'Object' to 'Integer'. Test/Test - Ship To Retag/Test - ShipToRetag - Read Input File.xaml