Reputation: 3823
How would you go about retrieving the @@IDENTITY value for each row when the SQLDataAdapater.Update is executed on a table?
eg. Is it possible to modify/intercept the InsertCommand, generated by the SQLCommandBuilder, to say add an output parameter, and then retrieve its value in the da.RowUpdated event???
Upvotes: 0
Views: 151
Reputation: 1010
This is an article that has proven to be quite useful, where the trick of "tweaking the InsertCommand" is explained, as well as the trick to set the query to "Scalar"
Bye!
Peter
Upvotes: 1
Reputation: 6783
Bill Vaughn knows a thing or two about this. They key is tweaking your InsertCommand.
See "Managing an @@IDENTITY Crisis".
Note: the actual solution uses SCOPE_IDENTITY() in order to be trigger-safe.
Upvotes: 1