Click here to Skip to main content
15,569,696 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

I have two datasets, they consist of the following:
the first dataset (ds1) contains one table which contains two columns (ID and counter)
the second dataset (ds2) contains exactly like the first dataset but of course with different data.

So I want to choose the data that achieves this condition:

and then put the new data in new dataset

thank you in advance

One way to do this is to use LINQ. To query the data, the code could be something like:
var result = from row1 in ds1.tables[0].AsEnumerable()
             join row2 in ds2.tables[0].AsEnumerable() 
                on row1.Field<decimal>("ID") 
                equals row2.Field<decimal>("ID")
             select row1;

The select portion in the example selects only the row1 in whole but you should modify it to fetch the desired results.

When the query is finished, you can use CopyToDataTable method to add the data into a new table.
Share this answer
You can actually directly filter within the DataSet on the id.
read more about this here[^].
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900