Showing posts with label sense. Show all posts
Showing posts with label sense. Show all posts

Saturday, March 24, 2012

Serialize DataTable

This just doesn't make sense to me at all. I know you can't return a DataTable from a web service method. I know the work around is to return a DataSet instead.

The DataTable can't be serialized and that's by design, according to MSDN. But the DataSet can, and the DataSet contains DataTables (probably). A DataTable obviously gets serialized when you serialize a DataSet, so why can't you just deal with the DataTable?I haven't tried it, but the DataTable (according to MSDN Library) is serializable:

<Serializable>
Public Class DataTable
Inherits MarshalByValueComponent
Implements IListSource, ISupportInitialize, ISerializable

If you are talking about the .WriteXml() method, then that is a whole different thing since it is an implementation thing.
Not sure about that, I guess I mean this (http://support.microsoft.com/default.aspx?scid=kb;en-us;306134). Like I said it's easy enough to work around, I just don't understand why it's like that.