When you use a dt.select, but there are no rows which conform to the formula, it will give you an error saying source contains no data rows.
In your example at the start, you have used the .select method to create a list of rows where Reg… is " ". if there are no rows which conform to this, it will break, not just return a zero.
A way to get around this is to use the filter datatable activity instead, which works in a similar way to the .select method, but will not error when zero is returned. if you do this before your ‘If’ statement, and in the ‘If’ condition have a simple dt.rows.count>0 you should be good to go
This is based on the previous task you helped me with.
Sometimes there is no “ja” in the column “Reg. på plats”
Thats why im looking for a way to use the If statement to look at the datatable and if everything is empty under “Reg. på plats” it should assign 0 to countJA otherwise it should do the “Then” part.
I dont really know I how i should use the things you described.
Start debugging till the point that tmpData is existing
Open watch panel
Copy statement in to the watch expression:
tmpDataTable.AsEnumerable.Any(Function ( r ) Not String.IsNullOrWhitespace(r([Reg. på plats).toString.trim))
an inspect the result true or false
If the statement is working as expected jus copy it into the if statement, that you have shown in the post above. Change for the true case the assignment to tmpData.Rows.Count