Search value in the datatable

I created a Datable with Scrapping Data and I want to select the line where more conditions.
In example, the number in first colum is “23” and the seventh column contains the letter “A”.

I searched… I found “DataTable.Select méthode (String)” but it’s not works.

Please provide your code or a similar enough example if you can’t share it directly.

Unfortunately “it doesn’t work” doesn’t give enough information to diagnose. But I can assure you that .Select method does work, so there has to be something specific to how the DT looks or how you’re using it.


DT_ExtractDataTable.Select(“Number=23” and Column7 contains “D”).
The syntax isn’t correct but after I want line who response by the select

Can you try

DT_ExtractDataTable.Select(“Number=23 and Column7 like ‘%D%’”).

Not works : compiler error… but how read the number line after ?

May be something with the quotes, can you share your code. I did not understand “but how read the number line after

Do you want to know how to read the output? The output is a DataRow Array and you can get the values by iterating in foreach loop.

try this:
for each row in ExtractedDatatable
if(Convert.ToString(row.Item(< columnIndex >)).Exact(“23”)=True)
use assign activity : value= Convert.ToString(row.Item(< columnIndex+1/ or any other column index >))


=>> Convert.ToString (Row.Item(2))="23 instead of Convert.ToString(row.Item(< columnIndex >)).Exact(“23”)=True

But : I would like to return the number of row who find the value.

Fist solution : counter with i++ and return i but I don’t like (vvaidya)
Second solution : use method with row but which ? (item ordinal ? other ?)

Thanks all

@Lorennzo I would like to return the number of row who find the value.

Do you mean number of rows returned?

dtRow = DT_ExtractDataTable.Select(“Number=23 and Column7 like ‘%D%’”)

rowsfound = dtRow.length

1 Like

Length is (definition) “The total number of elements in all the dimensions of the Array”.
Example :
1 2 3
ab ed ef
fd ed ea
ed ac ax

I select the Third line in my datatable with colum1=ed and colum3=ax
I want to return 3 (the line three)

As per your requirement, the output should be line 3. If you want to find out the line numbers, you have to use foreach loop of DataRow array since the result can be > 1 rows.Inside the foreach loop use the below logic:

foreach(row in RowArray)
int linenum = DT_ExtractDataTable.Rows.IndexOf(row);


Sorry, return always 1 for me.
An idea, I found maybe a method : BinarySearch but works only on a column I think.

@Lorennzo if return is always 1, below is the logic and no need of foreach

dtRow = DT_ExtractDataTable.Select(“Number=23 and Column7 like ‘%D%’”)
int linenum = DT_ExtractDataTable.Rows.IndexOf(dtRow(0)) + 1; (+1 since index starts from 0)


to get the row number use assign int index = dt.Rows.IndexOf(row);

1 Like

It works - Thank’s vvaidya and palindrome
It was my first Uipath progam !


I have two data tables,say dt1,dt2…i have to take one value say id, from dt1 and i have to search in dt2 with all id’s that are in dt2, and if found i have to copy remaining columns data from dt1 to dt2 for that id.can anyone please help me regarding what way i can use select function.

1 Like