there r 2 datasets and I want to get 3rd dataset containing the records which are common in 1st and 2nd datasets. common field in dataset 1 n 2 is id. what is the best method to do it?
get new dataset from common records of 2 sets
Collapse
X
-
I would loop through dataset1, and for each record loop through dataset2, adding the row only when it is in common.
Not very efficient (n^2) but the only way I know how. -
i thought the same way, loop through both datasets, but when i try to add common records in new dataset, it throws error, can you tell me by example?Originally posted by insertAliasI would loop through dataset1, and for each record loop through dataset2, adding the row only when it is in common.
Not very efficient (n^2) but the only way I know how.Comment
-
You need to use .ImportRow(data Row)Originally posted by Garima12i thought the same way, loop through both datasets, but when i try to add common records in new dataset, it throws error, can you tell me by example?
Example
That would copy row 0 from DataTable1 to DataTable2. That should be enough to get you started.Code://c# DataTable2.ImportRow(DataTable1.Rows[0]);
Comment
Comment