Is it possible to return just a DataTable from a WebMethod, instead of DataSet?

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default Is it possible to return just a DataTable from a WebMethod, instead of DataSet?

    Hi all,

    I just want to make sure i'm not doing anything stupid, but it seems to me
    that its not possible to return a simple datatable from a WebMethod - it has
    to be a full dataset.

    The online help seems to state that it is possible with either dataset or
    datatable (both remotable, both serializable), but only dataset works for
    me.

    If i try it with a datatable, when querying the asmx file, i get a message
    saying the object cannot be serialized becuase it is an interface. It works
    fine when the same datatable is added to a dataset.

    Is this correct or am i doing something silly?

    Additionally, if this is correct behaviour, could anyone tell my why it is?
    Both objects descend from MarshalByValue, and both have the same Interfaces
    according to the docs. Any ideas?

    Thanks in advance

    Tim


    Tim Medcalf Guest

  2. Similar Questions and Discussions

    1. Can Application_BeginRequest return a DataSet and stop normal webmethod flow?
      Hi, I am implementing a couple of webservices (all in the same web project) that will access several backoffice systems to get and update...
    2. Ccopying a datatable content from an untyped dataset into a table which is inside a typed dataset
      Hi All, I am facing problem in copying content of table from a untyped dataset into to a table inside the typed dataset. I wanted to copy the data...
    3. DataTable as parm to a WebMethod function?
      According to MS, DataTable cannot be passed or returned by a Web Service. Try using DataSet instead. Aleksey
    4. Pulling DataSet From WebMethod -- Possible?
      Is it possible to have a public WebMethod in a WebService that returns a DataSet? -- _____________________________ Ron Rodenberg Lead Software...
    5. DataTable parameter of a WebMethod?
      DataTable is not serializable, you have to put them in a dataset. DataTable object to it. I visit the .asmx can't pass in a...
  3. #2

    Default RE: Is it possible to return just a DataTable from a WebMethod, instead of DataSet?

    Hi Tim,

    A datatable can't be be serialized and cannot be returned from an XML Web
    service. and there has been a document for this issue:

    [url]http://support.microsoft.com/?kbid=306134[/url]

    Hope this help,

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    MSFT Guest

Posting Permissions

  • You may not post new threads
  • You may 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