DataRow, WebService question

Discussion in 'ASP .Net Web Services' started by Tim Mulholland, Aug 7, 2003.

  1. 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, Aug 7, 2003
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:%...
    > Tim,
    >
    > For solution #2, have you tried using the DataSet Merge method?
    >
    > Bill
    >
    >
    > "Tim Mulholland" <> wrote in message
    > news:...
    > > 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, Aug 7, 2003
    #2
    1. Advertising

  3. Tim Mulholland

    Bill Simakis Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:%...
    > > Tim,
    > >
    > > For solution #2, have you tried using the DataSet Merge method?
    > >
    > > Bill
    > >
    > >
    > > "Tim Mulholland" <> wrote in message
    > > news:...
    > > > 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, Aug 7, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ignacio Machin

    Re: Convert DataRow content to bool

    Ignacio Machin, Jul 7, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    365
    Ignacio Machin
    Jul 7, 2003
  2. Eliyahu Goldin

    Re: Convert DataRow content to bool

    Eliyahu Goldin, Jul 7, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    350
    Eliyahu Goldin
    Jul 7, 2003
  3. Ron Vecchi
    Replies:
    1
    Views:
    659
    Ron Vecchi
    Jul 27, 2003
  4. Ron Vecchi
    Replies:
    0
    Views:
    383
    Ron Vecchi
    Jul 30, 2003
  5. Ron Vecchi
    Replies:
    0
    Views:
    407
    Ron Vecchi
    Jul 31, 2003
Loading...

Share This Page