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.
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 >))
}
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);
}
@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)
HI,
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 this.in what way i can use select function.
thanks