deleting duplicates from dataset

Reptile

New member
Joined
Feb 23, 2007
Messages
1
Programming Experience
Beginner
Hi,

I have a dataset that contains duplicates. This is because it is populated by 4 different queries (the DataAdapter.Fill method is called for each query in particular).
What is the easiest way to remove these duplicates?
The dataset is finally displayed in a ReportViewer. I tried to filter the duplicates in there, but it didn't work.

Thank you in advance,

B.
 
Use a dictionary(of datarow, int) to keep track of the number of times a row has been seen.
Foreach row in the datatable
if the dictionary contains the row, delete the row (call row.delete())
else add the row to the dictionary

accept the changes to the datatable
 
Back
Top