Re: Merging rows with Identity col into orig DataSet after updatin
From: Nima (Nima_at_discussions.microsoft.com)
Date: 09/08/04
- Next message: Val Mazur: "Re: oledb version problem in connection string vb.net"
- Previous message: Rajesh Patel: "Re: certain column is unchangeable"
- In reply to: David Browne: "Re: Merging rows with Identity col into orig DataSet after updating DB"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 7 Sep 2004 19:11:02 -0700
Thanks David for the suggestion. When deleting a row that my binding manager
is pointing to, the binding manager ends up pointing to the previous row.
Then I have the problem of pointing the binding manager to the new row. I
can hack it, but this must be a common problem and I am pretty sure that it
has an elegant solution built into the framework that I am missing. Please
help.
"David Browne" wrote:
>
> "Nima" <Nima@discussions.microsoft.com> wrote in message
> news:5AE4E060-446D-49E8-8129-B91F549DC26F@microsoft.com...
> > Hello,
> >
> > I am trying to insert data into a database on the other end of a web
> > service. The primary key in my DataTable is an identity column. I first
> > get
> > a copy of my dataset with only the changes in it by calling
> > DataSet.GetChanges. I then pass this little DataSet across the wire where
> > my
> > insert stored procedure first inserts the records from the little DataSet
> > into the database and then the SELECT statements at the end of the stored
> > procedure updates my little DataSet so it gets the identity PK value from
> > the
> > database. I then pass this little DataSet back to my client and want to
> > merge it with my original DataSet.
> >
> > So lets say I insert a new row on the client, the DataSet will give it a
> > PK
> > value of -1 (my AutoIncrementSeed and AutoIncrementStep values are -1),
> > this
> > record is then sent to the server, the database is updated properly (via
> > DataAdapter.Update), the DataSet used for this is then updated with the
> > latest values from the data base (thanks to the SELECT statement at the
> > end
> > of my stored procedures). At this point the PK value is now say 34 (from
> > the
> > database). Now I ship this little DataSet back to the client and need to
> > merge its values with those in the bigger DataSet on my client. If I use
> > DataSet.Merge, the row with the -1 PK remains in the big DataSet and a new
> > row with PK of 34 is added to it.
> >
> > What is the best way / standard way to merge in a situation like this?
> >
>
> On the client, you could remove all the rows with negative numbers for the
> PK, and then merge.
>
> David
>
>
>
- Next message: Val Mazur: "Re: oledb version problem in connection string vb.net"
- Previous message: Rajesh Patel: "Re: certain column is unchangeable"
- In reply to: David Browne: "Re: Merging rows with Identity col into orig DataSet after updating DB"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|