Hey,
so I know I can use “Select” to create an Array of specific DataRows of a DataTable.
But I want to create an Array of ALL the DataRows in a DataTable.
I’m struggeling to use Select to get an Array with all the Rows.
1…you can use for each row loop activity buddy
the outcome of this loop will be a variable row, which will be type datarow
so you can get all the datarow of a table by just iterating with for each row loop
or
2. you can use assign activity with a variable of type array of datarowcollection and mention like this buddy
out_datarow_array = out_dt.Rows
or
3. you can get by the method you used buddy out_datarow_array = out_dt.Select()
where out_datarow_array is of type array of datarow
Yeah, thanks for your solutions, but unfortunately now I have a different problem…
So here is what I was trying to do:
I have two DataTables. I want to remove all the DataRows in the first DataTable that are duplicates in the second DataTable.
So I thought I could create an array of all the Rows in the second DataTable and remove them from the first DataTable… but that gave me an error. Guess I can’t remove the Items in the Array from the second DataBase from the first one.
Here is just another solution using LINQ that would look for each row in second table and not include it in first table: dt1.AsEnumerable.Where(Function(r1) dt2.AsEnumerable.Where(Function(r2) r2(0).ToString.Trim = r1(0).ToString.Trim ).ToArray.Count = 0 ).CopyToDataTable
0 index can be replace with “columnname” if desired, and for multiple criteria to match the row up, you can use AND, like r2(0).ToString.Trim = r1(0).ToString.Trim And r2(1).ToString.Trim = r1(1).ToString.Trim
Alternatively, you can use .ItemArray to compare the rows, assuming the rows will have identical values. dt1.AsEnumerable.Where(Function(r1) dt2.AsEnumerable.Where(Function(r2) String.Join(",",r2.ItemArray) = String.Join(",",r1.ItemArray) ).ToArray.Count = 0 ).CopyToDataTable