|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Applying changes to tableHi,
my client sends a dataset with changes to my server. These changes have been created by the GetChanges method of the dataset. What's the easiest way to update the table on the server with these changes? What a Stored Procedure look like to do this? Thanks for any advice in advance Anthony -- Anthony Malt Dear Anthony Malt,
A stored procedure example for insert as the following: -------------------------------------------------------------------- CREATE PROCEDURE StoredName (@VarName1 VarType, @VarName2 VarType) AS INSERT Into TableName VALUES(@VarName1, @VarName2) -------------------------------------------------------------------- Hope can help you, Regards Joe Tsui Show quote "Anthony Malt" wrote: > Hi, > > my client sends a dataset with changes to my server. These changes have been > created by the GetChanges method of the dataset. > > What's the easiest way to update the table on the server with these changes? > What a Stored Procedure look like to do this? > > Thanks for any advice in advance > Anthony > > -- > Anthony Malt > > > Anthony,
Use the dataadapter update method. Be aware that the GetChanges creates a copy of the changed rows of the dataset. Without a acceptchanges from the original dataset after the successful done update you are mostly in trouble. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqldataadapterclasstopic.asp For that you have to create the proper insert, update and delete command, for which you can use a commandbuilder or do it by hand. Be aware that you set the sql code to check the optimistic concurrency the meanwhile updated datarows by others. If the SQL statements are dynamic or in an stored procedure is not the most important part from this. If you don't use the commandbuilder than I would first try it dynamic (because it is not the simplest part) and than place those commands in a stored procedure. I hope this helps, Cor |
|||||||||||||||||||||||