Bestway to submit updated row in ds via webservice

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

I have a WinForms application that uses webservices for its data access.
Rather than having the user insert/update/delete multiple rows and then send
the dataset back to the server as a batch, I want to submit the changes back
to the server as each row is saved. what would be the best way to send a
dataset datarow back to sql server via a webservice? I know I can simply
use function and pass parameters back to a stored procedure, but I wanted to
explorer the options using the dataset technology since I'm already using
datasets to manage the data in the client app.

The 2nd part to this is if I use a data adapter on the backend to submit the
changes to the db, how can I return a new PK value on inserts? If this
isn't possible, then I may as well stick to passing parameters through the
webservice to a stored procedure to do updates and have the SP return the
new identity value.

Any recommendations?
 
I think I figured it out. Answer to the first part: to pass a single
datarow back to the server, just create a new dataset and add the datarow to
the dataset

Answer to the second part: If I want to return the new Identity value after
inserting via the data adapter, then use a stored procedure for the DA's
command text and have that SP return the identity value in an output
parameter. The data adapter wizard will pickup the output parameter and
write all the code for it. I just need to capture the output param's value
after the da runs.

This is theory, but it seems like it should work.
 
Hi moondaddy,

I recommend you to pass the DataRow as a parameter to the webservice. Since
you need to update the server as each row is saved, I think passing a
DataRow to the webservice is the best way. If you pass the whole dataset,
unnecessary data might be included, this might cause a performance hit.

You can use "SELECT SCOPE_IDENTITY() as IDColumn" to get the auto number
value as the primary key. However, it much complex that just pass a row.
You can refer to the following link for more information.

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3HibnTlfDHA
..2528%40cpmsftngxa06.phx.gbl&rnum=10

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "moondaddy" <[email protected]>
| Subject: Bestway to submit updated row in ds via webservice
| Date: Wed, 15 Oct 2003 23:34:08 -0500
| Lines: 21
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: adsl-66-137-118-208.dsl.hstntx.swbell.net
66.137.118.208
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:63743
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| I have a WinForms application that uses webservices for its data access.
| Rather than having the user insert/update/delete multiple rows and then
send
| the dataset back to the server as a batch, I want to submit the changes
back
| to the server as each row is saved. what would be the best way to send a
| dataset datarow back to sql server via a webservice? I know I can simply
| use function and pass parameters back to a stored procedure, but I wanted
to
| explorer the options using the dataset technology since I'm already using
| datasets to manage the data in the client app.
|
| The 2nd part to this is if I use a data adapter on the backend to submit
the
| changes to the db, how can I return a new PK value on inserts? If this
| isn't possible, then I may as well stick to passing parameters through the
| webservice to a stored procedure to do updates and have the SP return the
| new identity value.
|
| Any recommendations?
|
| --
| (e-mail address removed)
|
|
|
 
Hi moondaddy,

I'm glad to know that you've found the answer. What I mean in my last post
is similar to what you figured out.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "moondaddy" <[email protected]>
| References: <#[email protected]>
| Subject: Re: Bestway to submit updated row in ds via webservice
| Date: Thu, 16 Oct 2003 00:54:10 -0500
| Lines: 43
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: adsl-66-137-118-208.dsl.hstntx.swbell.net
66.137.118.208
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:63745
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| I think I figured it out. Answer to the first part: to pass a single
| datarow back to the server, just create a new dataset and add the datarow
to
| the dataset
|
| Answer to the second part: If I want to return the new Identity value
after
| inserting via the data adapter, then use a stored procedure for the DA's
| command text and have that SP return the identity value in an output
| parameter. The data adapter wizard will pickup the output parameter and
| write all the code for it. I just need to capture the output param's
value
| after the da runs.
|
| This is theory, but it seems like it should work.
|
|
| | > I have a WinForms application that uses webservices for its data access.
| > Rather than having the user insert/update/delete multiple rows and then
| send
| > the dataset back to the server as a batch, I want to submit the changes
| back
| > to the server as each row is saved. what would be the best way to send
a
| > dataset datarow back to sql server via a webservice? I know I can
simply
| > use function and pass parameters back to a stored procedure, but I
wanted
| to
| > explorer the options using the dataset technology since I'm already
using
| > datasets to manage the data in the client app.
| >
| > The 2nd part to this is if I use a data adapter on the backend to submit
| the
| > changes to the db, how can I return a new PK value on inserts? If this
| > isn't possible, then I may as well stick to passing parameters through
the
| > webservice to a stored procedure to do updates and have the SP return
the
| > new identity value.
| >
| > Any recommendations?
| >
| > --
| > (e-mail address removed)
| >
| >
|
|
|
 
I did the following :

use getchanges to get only the changed rows
pass this to the service
the service returns the updated dataset
meagre this back into the source dataset.

this works a treat unless you have AUTO NUMBER cols, but I did a work around
for this, let me know if ID cols will cause you problems.

If you do it ROW by ROW, it will be very CHATTY, just passing the dataset is
CHUNKY and CHUNKY is better.

Steve
 
Call HasChanges on DS then call GetChanges. Send the 'GetChanges' Dataset
to your web service, assuming the web service expects a Dataset.
 
great approach;. Remember, GetChanges returns a dataset so you do not have
to 'technically' create a new one and add your datarow to it.


moondaddy said:
I think I figured it out. Answer to the first part: to pass a single
datarow back to the server, just create a new dataset and add the datarow to
the dataset

Answer to the second part: If I want to return the new Identity value after
inserting via the data adapter, then use a stored procedure for the DA's
command text and have that SP return the identity value in an output
parameter. The data adapter wizard will pickup the output parameter and
write all the code for it. I just need to capture the output param's value
after the da runs.

This is theory, but it seems like it should work.


moondaddy said:
I have a WinForms application that uses webservices for its data access.
Rather than having the user insert/update/delete multiple rows and then send
the dataset back to the server as a batch, I want to submit the changes back
to the server as each row is saved. what would be the best way to send a
dataset datarow back to sql server via a webservice? I know I can simply
use function and pass parameters back to a stored procedure, but I
wanted
 
Back
Top