Above code is the code I run to filter the datatable where the row values are equal to invoice. I get the dbnull to type String error when there is a blank cel in the “INVOICE” row, its completely normal because it cannot convert null to String so I get the reason why I am getting the error message. BUT, the thing is I need it to be able to convert it as “” empty string. Is there any way of making this work?
invoke code … use it to check firstly if every case in every row contains data, if yes then keep the loop if not assign =“” to the cell which will be empty. then after this u can use the code above to do ur action.
Hope its helpful.
(From d in dt.AsEnumerable
Where Not (isNothing(d(“INVOICE”)) OrElse String.IsNullOrEmpty(d(“INVOICE”).toString.Trim))
Where d(“INVOICE”).toString.Trim.Equals(invoice.trim.ToString)
Select d).CopyToDataTable
Kindly note:
x(“INVOICE”)).toString returns a string. Prepended CStr converts a string into string and can be ommited
Sequence: The source contains no DataRows. This is the error code I got
" dt.AsEnumerable.Select(Function ( r ) r(“Invoice Number”).toString.Trim).Distinct().toArray " I use this to get the distinct invoices to filter acording to those numbers. So when I do this in a scenario where there is an empty invoice the array becomes as (“something”,“”), so ı process “something” its flawless but when the invoice is “” I got the above error using ur filter.