Comparing two datasets

G

Guest

Hi

How to compare two datasets? Is there any method available

I have two datasets with one table each.Both contains around 30,000 records.I want to check records which are not in second dataset but present in first dataset

Any kind of help is appreciated

Thanks in advance.
 
C

Cor

Hi Kshitij,

There is not a "method"

A method to use will be if they have a primary key use the
while looping throught one use datarowcollection.find on the other one

or if not

use the dataview for both and use for both the sort and while looping every
time the rowfilter and see if the dv.count<>0.

Just my thougth about it.

Cor
 
U

Uri Dor

if the SQL statements filling each are constant, you can create an SQL
that would do that work for you - something like select * from
first_table where id not in (select id from second_table)
 
G

Guest

What you may be able to do is for dataset 2 (DS2), register an event handler for its table's RowChanging or RowChanged event handler. Then do a merge like DS2.Merge(DS1), any rows being added will fire the event with the action of Added and you can log the row that was added. I haven't tried this though I think it should work

But here is another way that should work. If you just do DS2.Merge(DS1), any rows added to DS2 table will have the RowState of Added. You can then do a DataView of the table with the RowStateFilter property = DataViewRowState.Added. This should give you what you need. If you can't modify DS2 you can reject the changes after the merge and getting the information you need or you could do a dataset.copy first to temp dataset.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top