This loop error is in the other loop

I have a For each row loop inside another for each row loop and my 2 datatables have the same number of columns, just different values. I compare and assign the value back into the outer loop

code to get value: CStr(if(CurrentRowDTtoday(0).ToString.Contains(rowitem(0).ToString),Cint(rowitem(“Number of reminders”).ToString)+1,0)))

but when calling value from inner loop i don’t get it. Can anyone tell me why and is there another solution to this problem (linQ for example)?. I have attached a picture below. Thank you

@NguyenThinh

can you share the sample input and expected so that we can help you with you linq or another approach

unfortunately db_OutPut cannot be inspected from the screenshot

for a more reliable tracing within the debugging panels put a comment activity under the assign activity (where the IF… is used). So we can rely that it is entered safe enough into the scope od rowitem

I a lot of scenarios we also have other option for pairing / comparing 2 datatables.

What is tried in detail?

I have 2 input tables as shown. If the value in column(0) of input1 appears in column(0) of input2, the value of column(last) of input2 will be added to 1. For example, if OR02826553 appears in both input tables, then The value of column(last) input 2 is 2+1 = 3 and if not then the value is filled in with 0

Input 1:

Input 2:

I have 2 input tables as shown. If the value in column(0) of input1 appears in column(0) of input2, the value of column(last) of input2 will be added to 1. For example, if OR02826553 appears in both input tables, then The value of column(last) input 2 is 2+1 = 3 and if not then the value is filled in with 0. So I use a loop of 2 for each row to check them

Input 1:

Input 2:

@NguyenThinh

use this in invoke code

you can refer this

For Each row1 As DataRow In dt.AsEnumerable
For Each row2 As datarow In dt2.AsEnumerable
If row1(0).ToString.Trim.Equals(row2(0).ToString.trim) Then
row2(“Number of reminders”)=CInt(row1(“Number of reminders”).ToString)+1
Else
row2(“Number of reminders”)=“0”
End If
Next
Next

Sequence8.xaml (11.6 KB)

we would recommend to shift to other techniques like joining / lookup / lkDictionaries / LINQ instead of using 2 nested loops

  • we are independend on the row positions from the lookup datatable
  • we have a chance to reduce the mass of touched lookup rows to a minimum

Thank you guys for helping me

Thanks for helping me

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.