Re: Comparing two DataSets with a Merge

From: Joe Sullivan (JoeSullivan_at_discussions.microsoft.com)
Date: 12/09/04


Date: Thu, 9 Dec 2004 09:51:10 -0800

I am not adding any rows. Forget about adding rows. In my example, I am
CHANGING a row. An ADO.NET RecordSet keeps track of the previous and current
values when a recordset row changes. You can then call the GetChanges()
method to return only the rows that have been changed (the recordset keeping
track of the previous and current values). I could effectively end up with
the kind of merge I want if I looped through the rows of the first dataset
and updated any columns that were different from the second dataset and then
called the GetChanges method. However, I am trying to avoid looping through
the rows. Again, the end result here is a dataset containing only the
changes.

Thanks for your help,
Joe

"Cor Ligthert" wrote:

> Joe,
>
> I dont think that the merge will help you with that.
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatasetclassmergetopic.asp
>
> See this row in the sample
>
> ' Add two rows. Note that the id column can't be the
> ' same as existing rows in the DataSet table.
>
> What you want is in my opinion a "Match and Replacerows", which I have never
> seen in ADONET.
>
> Cor
>
>
> "Joe Sullivan" <JoeSullivan@discussions.microsoft.com>
>
> > What I am attempting to do is update data on our live sql server that has
> > been changed over time offsite and saved in an access database. I can't
> > just
> > call the GetChanges() method of the dataset because I want to make sure
> > that
> > I get all changes across multiple runs of the application (this is an
> > offline
> > application that may not always be running).
> >
> > I am attempting to create an XML file that contains only changes to the
> > data. I figured that I could save the changes across multiple runs in the
> > access database. Then, when I am ready to synchronize with our database
> > on
> > the server, I could load the live data into a dataset and compare it with
> > the
> > dataset from the access database to just return the changed data (I cannot
> > update the tables through SQL code... I have an api that I am going to run
> > through the changes with).
> >
> > For example, say that we have changed the third column of the 1st row in
> > my
> > offline access system....
> >
> > In dsLive,
> > 1, "John Doe", 100
> > 2, "Jane Doe", 200
> >
> > in dsAccess:
> > 1, "John Doe", 200
> > 2, "Jane Doe", 200
> >
> > I want a resulitng dataset that shows the changed row:
> > current version: 1, "John Doe", 200
> > previous version: 1, "John Doe", 100
> >
> > Which is what I hoped to see in dsLive by calling dsLive.Merge(dsAccess).
> >
> > All I want to do is to update the live dataset with the access dataset and
> > take advantage of versions in the dataset to compare previous and current
> > versions.
> >
> > Thanks,
> > Joe
> >
> > "Cor Ligthert" wrote:
> >
> >> Joe,
> >>
> >> Merging from two datasets to compare should be always impossible.
> >> The tables that has to be merged needs the same primary key at least and
> >> there should not be the same key in the destiniation table as in the
> >> sending
> >> table.
> >>
> >> Your code makes now probably only an extra table in your dataset.
> >>
> >> A dataset is an object that holds tables objects, which hold row objects,
> >> which holds item objects.
> >>
> >> So that easy is it not to compare.
> >>
> >> Therefore what is it you want to compare?
> >>
> >> Cor
> >>
> >> "Joe Sullivan" <Joe Sullivan@discussions.microsoft.com>
> >>
> >> >I am trying to find the difference between two datasets. I have tried
> >> > merging the two datasets and then writing an xml diffgram like so:
> >> >
> >> > dsA.AcceptChanges();
> >> > dsA.Merge(dsB, true);
> >> > dsA.WriteXml("D:/dev/Changes.xml", XmlWriteMode.DiffGram);
> >> >
> >> > It would make sense that the merge would only change the records in dsA
> >> > that
> >> > are different from dsB. However, when I look at the XML file, it is
> >> > showing
> >> > every row as "modified" event when the previous and current values are
> >> > the
> >> > same.
> >> >
> >> > Am I doing something wrong here, or will it always show every row as
> >> > modified when I execute the merge method. Or, does someone know of a
> >> > better
> >> > way to show differences between two similar datasets. I am trying to
> >> > aviod
> >> > parsing through every row if at all possible.
> >> >
> >> > Thanks,
> >> > Joe Sullivan
> >> > joe.sullivan@gcmweb.org
> >> > Data Systems Administrator
> >> > Great Commission Ministries
> >> >
> >> >
> >> >
> >>
> >>
> >>
>
>
>



Relevant Pages

  • Re: Excel to Access and Access to Excel
    ... This code, connects to a Access database, sorts the contents of the ... excel sheet, & transfers the data to a table in the Access database. ... Dim objCommand As ADODB.Command ... ' open the recordset ...
    (microsoft.public.excel.programming)
  • Import Data from Access via DAO
    ... table tblSales has the following structure: ... It contains data for 200 Customers and each Customer has 4 records ... ' Select the MS Access Database that houses the data ... Dim DB As Database, RS As Recordset ...
    (microsoft.public.excel.programming)
  • Re: Excel to Access and Access to Excel
    ... This code, connects to a Access database, sorts the contents of the ... excel sheet, & transfers the data to a table in the Access database. ... Public Function Databaseconnect() ... ' open the recordset ...
    (microsoft.public.excel.programming)
  • Re: Row cannot be located for updating
    ... "David Beers" wrote in message ... > intermediate Access database, and then synchronizes the data with a Palm ... Then the recordset gets passed to another part of the ...
    (microsoft.public.vb.database.ado)
  • Use ADO to add or update date in Access
    ... I have an employee evaluation form in Excel. ... The primary key name RACFID is located in cell A1, ... ' exports data from the active worksheet to a table in an Access database ... ' open a recordset ...
    (microsoft.public.excel.programming)