Comparing Datasets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey,

I am stuck on this little problem, I have a database which I use to fill a
dataset when my application loads, however at certain intervals Im filling
another dataset using the same database. What i need to do is find any new
records added. Ive tried all kinds of thinks like DataSet.Merge e.t.c but
just can seem to get the right code combination to find the new records, any
feedback will be really appreciated.

Regards

James
 
Hi James,

Do you have an autoinc primary key?
You'll need an incrementing field to find the new records - or if you want,
all records that doen't appear in first dataset are new (you'll have to use
primary key or any other unique field to do this)
 
Miha,

Yer they have a primary key although its not auto Inc'd but is unique, what
im stuck is how id actually just say build a dataset filled with all the new
records, Im just confussed as to how to compare them and get the new records
out. Any tips welcome

Regards

Jame
 
If you have an incrementing key (perhaps timestamp?), you would just do a
"select ... where key>lastkey".
Since you don't have such a thing you have several options.
You might use a select ... NOT IN (all keys that you have already loaded) or
you might load all records and for each record look into the original
dataset (using key) if it already exists.
Something like that...
 
Back
Top