How to refer to a specific index in a datatable

I have three datatables D1 D2 and D3
D1 and D2 each contains a row of information.
D3 contains D1 and D2’s information in the same format.vI need to check if the information contained for each row matches. ie. D3’s row 0 is the same as D1 or D3’s row 1 is the same as D2.
The rows of information in D3 are distinguished by a unique ID string which is also included in D1 and D2.
I used lookup datatable to find the row containing the ID string in D3.

Then i wanted to iterate through the columns in D1, and on each item, iterate through D3 at that specific row index to see if that item is in D3. And i want to repeat that for all the items in D1.

I tried that with foreach row then foreach col but I can’t figure out how to refer to the cell I am currently on

Is there any way to do this like that? or a better method?

1 Like

Hi @zham667

If you know the rowIndex then you can get/update the cell value in this way

DataTable.Rows(0)(0)

Above code will give you the value of cell at Row 0 Col 0

To iterate in this you can create your own nested loop on the basis of row count and column count, but before this if you can do this with datatable.select statement that would be much faster

Thanks,
Prankur

3 Likes