Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Services (http://www.velocityreviews.com/forums/f64-asp-net-web-services.html)
-   -   DataRow, WebService question (http://www.velocityreviews.com/forums/t781455-datarow-webservice-question.html)

Tim Mulholland 08-07-2003 01:24 PM

DataRow, WebService question
 
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



Tim Mulholland 08-07-2003 03:41 PM

Re: DataRow, WebService question
 
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

"Bill Simakis" <Bill@nospam.ca> wrote in message
news:%23jW5bDPXDHA.652@tk2msftngp13.phx.gbl...
> Tim,
>
> For solution #2, have you tried using the DataSet Merge method?
>
> Bill
>
>
> "Tim Mulholland" <tim@eyeresponse.com> wrote in message
> news:uJVC2cOXDHA.2424@TK2MSFTNGP12.phx.gbl...
> > 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
> >
> >

>
>




Bill Simakis 08-07-2003 06:17 PM

Re: DataRow, WebService question
 
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

"Tim Mulholland" <tim@eyeresponse.com> wrote in message
news:uCmxdpPXDHA.2576@TK2MSFTNGP09.phx.gbl...
> 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
>
> "Bill Simakis" <Bill@nospam.ca> wrote in message
> news:%23jW5bDPXDHA.652@tk2msftngp13.phx.gbl...
> > Tim,
> >
> > For solution #2, have you tried using the DataSet Merge method?
> >
> > Bill
> >
> >
> > "Tim Mulholland" <tim@eyeresponse.com> wrote in message
> > news:uJVC2cOXDHA.2424@TK2MSFTNGP12.phx.gbl...
> > > 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
> > >
> > >

> >
> >

>
>





All times are GMT. The time now is 12:16 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57