Hello all,
I am using the reframework, and at time to proceed for each transaction as datarow variable, I would like to know how can I check if some value of the datarow transaction to proceed is empty.
Can you help me with this issue?
Thanks!
Hello all,
I am using the reframework, and at time to proceed for each transaction as datarow variable, I would like to know how can I check if some value of the datarow transaction to proceed is empty.
Can you help me with this issue?
Thanks!
Hi @Angel_Llull,
I usually do this check:
row("ColumnName") IsNot Nothing AndAlso Not String.IsNullOrEmpty(row("ColumnName").ToString)
Thanks for the answer!
But the issue is that I dont know which row of which column can be empty. One day is column A, and another day is Column D…
Do you want to know what columns have empty values?
Also, it need to be dynamic because you are not sure what are the column names. I mean, they can vary. Am I right?
Yes, I want it dynamic. I want that robot checks if any column from the row is empty. So this transactions pass to business exception
Hey @Angel_Llull ! Convert DataRow to array with
Datarow.ItemArray
Then check if the array contains null value! With this:
arr_vals.Where(Function(x) String.IsNullOrWhiteSpace(x.ToString)).ToArray.Length > 0
Hope it helps!
Thanks! I will try it
Awesome solution @gabrielribas4
Thanks bro @gustavo.cervelin!!
Hello @gabrielribas4,
I have a question about the solution, as I am getting an error because there are rows with empty columns that the error is not throwing. I mean, these rows with empty values should not continue the process, and with the function above it is like it is not finding that theses values are empty…
Is that function checkin if all array is empty?
Thanks
Hey @Angel_Llull !! Lets try another approach:
arr_vals Is Nothing OrElse arr_vals.Length = 0 OrElse arr_vals.Where(Function(x) String.IsNullOrEmpty(x.ToString)).ToArray.Length > 0
Let me know if it works!!
checking datarow level
for any column value is null/Empty (assumption: simple datatypes for the columns)
isBlank = row.ItemArray.Any(Function (x) isNothing(x) OrElse String.IsNullOrEmpty(x.toString.Trim))
Checking entire Datatable Level (all rows, all columns)
hasBlanks =
(From d in dtDataVar.AsEnumerable
Let chk = d.ItemArray.Any(Function (x) isNothing(x) OrElse String.IsNullOrEmpty(x.toString.Trim))
Select x=chk).Any(Function (x) x)