473,569 Members | 2,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.InvalidO perationExcepti on: There was an error generating the XML
document. ---> System.InvalidO perationExcepti on: Cannot serialize the
DataTable. DataTable name is not set.
at System.Data.Dat aTable.WriteXml Schema(XmlWrite r writer, Boolean
writeHierarchy)
at
System.Data.Dat aTable.System.X ml.Serializatio n.IXmlSerializa ble.WriteXml(Xm lWriter writer)
at
System.Xml.Seri alization.XmlSe rializationWrit er.WriteSeriali zable(IXmlSeria lizable
serializable, String name, String ns, Boolean isNullable, Boolean wrapped)
at
Microsoft.Xml.S erialization.Ge neratedAssembly .XmlSerializati onWriter1.Write 2_DataTable(Obj ect o)
at
Microsoft.Xml.S erialization.Ge neratedAssembly .DataTableSeria lizer.Serialize (Object objectToSeriali ze, XmlSerializatio nWriter writer)
at System.Xml.Seri alization.XmlSe rializer.Serial ize(XmlWriter xmlWriter,
Object o, XmlSerializerNa mespaces namespaces, String encodingStyle, String id)
--- End of inner exception stack trace ---
at System.Xml.Seri alization.XmlSe rializer.Serial ize(XmlWriter xmlWriter,
Object o, XmlSerializerNa mespaces namespaces, String encodingStyle, String id)
at System.Xml.Seri alization.XmlSe rializer.Serial ize(XmlWriter xmlWriter,
Object o, XmlSerializerNa mespaces namespaces, String encodingStyle)
at System.Xml.Seri alization.XmlSe rializer.Serial ize(XmlWriter xmlWriter,
Object o, XmlSerializerNa mespaces namespaces)
at System.Xml.Seri alization.XmlSe rializer.Serial ize(TextWriter
textWriter, Object o, XmlSerializerNa mespaces namespaces)
at System.Xml.Seri alization.XmlSe rializer.Serial ize(TextWriter
textWriter, Object o)
at System.Web.Serv ices.Protocols. XmlReturnWriter .Write(HttpResp onse
response, Stream outputStream, Object returnValue)
at System.Web.Serv ices.Protocols. HttpServerProto col.WriteReturn s(Object[]
returnValues, Stream outputStream)
at System.Web.Serv ices.Protocols. WebServiceHandl er.WriteReturns (Object[]
returnValues)
at System.Web.Serv ices.Protocols. WebServiceHandl er.Invoke()

Does anybody know what the problem is? I thought DataTables were
serializable in .NET 2.0.
Nov 24 '05 #1
2 37205
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
5390
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 System.ComponentModel.MarshalByValueComponent.Site of type System.ComponentModel.ISite because it is an interface. I tried a number of workarounds without sucess:
2
3088
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 format. I can, of course, serialize a class to a file, either binary or XML, but this is not what I am looking for. Currently I am using ToString() or...
1
1644
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
5230
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 structures? Thanks for any hints, Leszek Taratuta
3
8071
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 statement to VB.NET and this is crucial: re-implementing ISerializable.GetObjectData() in the DataTable derived class so serializing the datatable derived...
4
5895
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
1477
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 Web Reference i am getting reference as (Partial Class name) Partial Class GetDataResponseGetDataResult
4
7105
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, created by XML file. I am taking one of the datatable from this dataset and want to filter on that datatable using Select() method. Now here the...
4
3282
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 stored objects of type String, DateTime, and ArrayList, for example. So I then tried an unbound DataGridView but it serialized with a null value. I...
0
7697
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7968
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.