DataRow, WebService question

T

Tim Mulholland

I am writing a WindowsForms based application that uses WebServices to add
records to a SQL Server database, and later query those, and other records.

My initial thought was to have one WebService return a new DataRow (having
gotten it by calling .NewRow() on a dataset), populate it, and then call
another WebService that accepts the full DataRow object and adds it to the
table.

I came to find out, DataRows are not serializable for WebServices. The MSDN
documentation said to always use a DataSet instead of a DataRow, DataTable,
etc. when working with WebServices.

This would seem to necessitate one of two things: 1) Returning the entire
DataSet (with thousands of records) from SQL Server, or 2) Creating a
temporary DataSet with the same structure and using a NewRow off of that.

#1 seems so inconvenient, that i'm sure #2 would be the best option. But in
my experience, if you create a row in one DataSet, and then try to do a
Rows.Add() to another DataSet, this generates an error saying that the row
already belongs to another table.

Am i missing something? Is there a way to change the table that a DataRow
object belongs to (assuming you're changing it to one with the same
structure)? Or is my approach here totally wrong and there's something alot
simpler? :)

Thanks in advance!

Tim
 
T

Tim Mulholland

No i hadn't looked into it - in fact, i had totally forgotten that it
existed.
Looking at the documentation, this looks like it would work perfectly - but
since i'm not sitting at the computer with the code on it, i'd like to just
verify something real quick if you dont mind:

I can create a dataset with the same schema in my webservice and return
that. Then, in my code i can add rows to it all i want (even multiple rows
if i felt like it). I can then pass that whole dataset back in through a
webservice and in that webservice, i can merge the data back together, and
update the physical table.
If that's all true, then that's wonderful.
Thanks alot Bill !

Tim
 
B

Bill Simakis

Tim,

That is what the framework promises. I haven't tried it myself, I just
remembered reading about it when I was looking into solving another problem.

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top