|
Re: Merging DataSet (Added and Unchanged): msg#00360windows.devel.dotnet.winforms
Greg, I just fixed a bug today having to do with this subject. We have a remoted method that passes back a DataSet with a DataTable containing a single (new) row. Since this is a typed DataSet with AutoIncrement turned on for the primary key columns, the PK for the returned row is always -1. Prior to the bug fix, we were merging the returned DataSet into our master DataSet on the client. This works fine the first time, but the second and subsequent times it overwrites the row merged in on the previous execution. The fix was to write a routine that adds a new (empty) row and copies all of the non-PK fields from the returned row, instead of doing the Merge. Bill On Wed, 25 Feb 2004 09:57:15 -0500, Greg Robinson <greg@xxxxxxxxxx> wrote: >The docs state > >"When merging a new source DataSet into the target, any source rows with a >DataRowState value of Unchanged, Modified, or Deleted, are matched to target >rows with the same primary key values. Source rows with a DataRowState value >of Added are matched to new target rows with the same primary key values as >the new source rows." > >This part: > >"Source rows with a DataRowState value of Added are matched to new target >rows with the same primary key values as the new source rows." > >h > >as always confused me. Our app sends an Added DataRow to our DAL (we call >the client Dataset's GetChanges method and send this smaller DataSet across >the wire). > >Our DAL does the insert. A primary key is returned as part of the insert. >The DataRow now has the PrimaryKey value and is now marked as Unchanged. >The client 'Added' DataRow does not have the PrimaryKey though. It is >storing a dummy PrimaryKey. > >So, we return to the client with an Unchanged DataRow that is storing the >correct PrimaryKey from sql server. > >So, how can this 'match' work? The Source DataRow is marked as Added. >However, the returning DataRow's PrimaryKey will never match. > >What we do now, is just prior to calling Merge, we remove all Added DataRows >from the client DataSet. The we call Merge. > >This works, but seems like extra overhead to me. > >Greg Robinson >Custom Data Systems, Inc. >www.cds-am.net |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Merging DataSet (Added and Unchanged): 00360, philip sayers |
|---|---|
| Next by Date: | Re: SQL: 00360, Andrew Dunn |
| Previous by Thread: | Re: Merging DataSet (Added and Unchanged)i: 00360, philip sayers |
| Next by Thread: | Re: Merging DataSet (Added and Unchanged): 00360, Block, Jeffrey A. (Jeff) |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |