Professional Web Applications Themes

DataRow, WebService question - ASP.NET Web Services

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 doentation said to always use a DataSet instead of a DataRow, DataTable, etc. when working with WebServices. This would seem to necessitate ...

  1. #1

    Default 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
    doentation 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 Guest

  2. #2

    Default Re: DataRow, WebService question

    No i hadn't looked into it - in fact, i had totally forgotten that it
    existed.
    Looking at the doentation, 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" <Billnospam.ca> wrote in message
    news:%23jW5bDPXDHA.652tk2msftngp13.phx.gbl...
    > Tim,
    >
    > For solution #2, have you tried using the DataSet Merge method?
    >
    > Bill
    >
    >
    > "Tim Mulholland" <timeyeresponse.com> wrote in message
    > news:uJVC2cOXDHA.2424TK2MSFTNGP12.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
    > > doentation 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 Guest

  3. #3

    Default 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" <timeyeresponse.com> wrote in message
    news:uCmxdpPXDHA.2576TK2MSFTNGP09.phx.gbl...
    > No i hadn't looked into it - in fact, i had totally forgotten that it
    > existed.
    > Looking at the doentation, 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" <Billnospam.ca> wrote in message
    > news:%23jW5bDPXDHA.652tk2msftngp13.phx.gbl...
    > > Tim,
    > >
    > > For solution #2, have you tried using the DataSet Merge method?
    > >
    > > Bill
    > >
    > >
    > > "Tim Mulholland" <timeyeresponse.com> wrote in message
    > > news:uJVC2cOXDHA.2424TK2MSFTNGP12.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
    > > > doentation 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 Guest

Similar Threads

  1. WebService question
    By Ido Samuelson in forum ASP.NET Web Services
    Replies: 1
    Last Post: August 26th, 01:32 AM
  2. DataRow
    By Nabeel Moeen in forum ASP.NET Data Grid Control
    Replies: 5
    Last Post: March 4th, 09:25 PM
  3. CF and webservice interaction question.
    By Nick in forum ASP.NET Web Services
    Replies: 0
    Last Post: February 16th, 11:00 PM
  4. webservice - newbie question
    By Mr. x in forum ASP.NET Web Services
    Replies: 0
    Last Post: September 12th, 01:32 PM
  5. DataRow[] and Select(filter with a like clause) question
    By Ron Vecchi in forum ASP.NET General
    Replies: 2
    Last Post: July 30th, 01:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139