G
Guest
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?
Thanks, thanks, thanks
Nima
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?
Thanks, thanks, thanks
Nima