I would like to know how to use foreachrow in column A of datatable dt. Do I need to assign it as a variable? I would then like to see whether this row in column A has same value in a cell in datatable dt2.
In dt2 you got a value of a cell say from third row and second column of the table with a assign Activity like this Out_value = dt2.Rows(2)(1).Tostring
Where 2 represents the third row and
1 represents the second column
As both row and COLUMN index starts from 0
and Out_value is a variable of type string
Now if you want to check this value with all the row in a column in datatable dt…
For that kindly follow the below steps that could help you resolve this issue buddy
–use a for each row loop and pass the input as dt
–inside the for each row loop use a if condition like this row(“YourColumnName”) ToString.Contains(Out_value)
If this condition gets passed it will go to THEN part of if condition where we can use the message box…with a string message within double quotes
Thats all buddy you were almost done
Kindly try this and let know whether this works or not
Cheers @mzucker
Thanks @Palaniyappan, really helpful mate.
If I want to cross reference with a whole column in dt2 (not just one cell) would I then right Out_value=dt2.Rows(“ColumnName”).ToString
Or to be more simple
–use a for each row loop and pass the input as dt and change the variablename from row to row1
–within this for each row loop use another for each row loop and pass the input as dt2 and change the variable name from row to row2
–in the inner for each row loop use a if condition like this row1(“YourColumnName”).ToString.Contains(row2(“YourColumnName”). Tostring)
And If this condition gets passed it will go to the THEN part of if condition
Where we can use a string called “OK”
–But make sure that we have used a break Activity next to message Activity or any other Activity in the THEN part of if condition at the last that would break and come out from the inner loop to outer for each loop to avoid matching again in the inner loop, to avoid redundancy
Thats all buddy
Hope this would help you
Kindly try this and let know for clarification
Cheers @mzucker
Sorry I think I was not clear enough, I would like to simply check for each row in column “A Code” of datatable dtA to see whether that same value is in column “B Code” of datatable dtB without having to retrieve the index of dtB (just a simple check to see if its in it.)
So is
dtBCodes = dtB(“B_code”).ToString
for each row in dtA
row(“A_code”).ToString.Contains(dtBCodes)
Then OK
Else Not OK