473,320 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Serializing a DataTable

I'm building a Web Service with the CLR 2.0 that returns a DataTable but I
get the followng error:

System.InvalidOperationException: There was an error generating the XML
document. ---> System.InvalidOperationException: Cannot serialize the
DataTable. DataTable name is not set.
at System.Data.DataTable.WriteXmlSchema(XmlWriter writer, Boolean
writeHierarchy)
at
System.Data.DataTable.System.Xml.Serialization.IXm lSerializable.WriteXml(XmlWriter writer)
at
System.Xml.Serialization.XmlSerializationWriter.Wr iteSerializable(IXmlSerializable
serializable, String name, String ns, Boolean isNullable, Boolean wrapped)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriter1.Write2_DataTable(Object o)
at
Microsoft.Xml.Serialization.GeneratedAssembly.Data TableSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle)
at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces)
at System.Xml.Serialization.XmlSerializer.Serialize(T extWriter
textWriter, Object o, XmlSerializerNamespaces namespaces)
at System.Xml.Serialization.XmlSerializer.Serialize(T extWriter
textWriter, Object o)
at System.Web.Services.Protocols.XmlReturnWriter.Writ e(HttpResponse
response, Stream outputStream, Object returnValue)
at System.Web.Services.Protocols.HttpServerProtocol.W riteReturns(Object[]
returnValues, Stream outputStream)
at System.Web.Services.Protocols.WebServiceHandler.Wr iteReturns(Object[]
returnValues)
at System.Web.Services.Protocols.WebServiceHandler.In voke()

Does anybody know what the problem is? I thought DataTables were
serializable in .NET 2.0.
Nov 24 '05 #1
2 37162
Jayne

Trying using the tablename property to assign your datatable a name
before serializing it.

Peter Kelcey

Nov 24 '05 #2
Thanks Peter. That worked a treat.

Jayne

"Peter Kelcey" wrote:
Jayne

Trying using the tablename property to assign your datatable a name
before serializing it.

Peter Kelcey

Nov 24 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris | last post by:
I'm having trouble Serializing a System.Data.DataColumn object. When I try to serialize it, I get the following: System.NotSupportedException: Cannot serialize member...
2
by: Earl Teigrob | last post by:
I am saving and restoring value types such as Int32, DateTime and Boolean in strings. I was wondering if there is a mechanism build into .NET for serializing and deserializing these to string...
1
by: JavedIqbal | last post by:
i want to serialize a string into a file in net 2.0. i also want to serialzie a datatable into a file. Can anyone guide me in this regard.
13
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data...
3
by: Frans Bouma | last post by:
Hi, I have a serious problem with VB.NET and a DataTable derived class and I can't figure out how to solve it. I have implemented it in C# where it works perfectly, but I can't port one...
4
by: Sean Feldman | last post by:
Hello, I've installed WSE2 and succedded to download from WebService DataTable object, but can't do the oposite. Anyone can help please? Thanks a lot!
0
by: Shell | last post by:
As i am passing datatable from webservice to UI My Web Method is as follows :- Public Function GetData() As DataTable Dim objData As New MyClass Return objData.GetData() End Function In my...
4
by: Aryan | last post by:
Hi, I am having problem with DataTable.Select() method. I am using ASP.NET 2.0. I have DataSet which reads data from XML file using DataSet.ReadXML(). Now this dataset has various datatable,...
4
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have been experimenting with how to properly store objects into persistent application settings in user.config. I have read everything I could on MSDN (and elsewhere) and I have successfully...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.