473,499 Members | 1,808 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to serialize a DataRow ?

I have a DataRow that I need to send it to another process as a XML string by
remoting.
Bu I do not want the other process to be familiar with the schema or
DataTable and DataRow structure, so I tried to serialize it to a XML string
but I get an exception saying the DataRow as no public data.
The code I tried to use
XmlWriter writer = new XmlTextWriter(new System.IO.StringWriter());
// Throw an exception !
XmlSerializer serializer = new XmlSerializer(typeof(DataRow));
serializer.Serialize(writer, myDataRow);
string xmlStr = writer.ToString();
writer.Close();
Is there a way to convert a DataRow to an XML string ?
---------
Thanks
Sharon
Nov 24 '05 #1
3 17544
Hi Sharon,

The XmlSerializer requires the type of the object to be serialized has a
public default constructor like public DataRow(). However, the DataRow
doesn't have one. So in this case, we can only put the whole DataSet or
DataTable into an Xml doc and then get the row needed from the xml doc. Or
you can try the BinaryFormatter to serialize it instead. But in only
returns byte array instead of a string.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 25 '05 #2
Is there any other way I can serialize a DataRow into XML string ?
-----
Thanks
Sharon
Nov 27 '05 #3
Sorry, Sharon. But as far as I know, currently, no. Sorry for the
inconvenience.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 28 '05 #4

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

Similar topics

5
24657
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
10
4121
by: Dan | last post by:
All I Am Attempting To Serialize An Object To An XML File. Here Is The Code For That public string SaveNewSurvey( MutualSurveyObject mso_TempObject, int i_JobID ) { string s_RootFileName;...
3
10370
by: MAY | last post by:
Hi, I have a problem about serialize the form controls. I wrote a test program to test serialize a from but fail (->An unhandled exception of type...
3
7546
by: Toxick | last post by:
Hello experts, I'm a total C# noob with a total C# noob question. I've been Serializing in C++ (MFC) and writing data to std::fstreams for quite some time, so maybe I'm not understanding...
1
1468
by: js | last post by:
Does anybody knows how to solve the problem? I added attribute to the following classes in Microsoft.Practices.EnterpriseLibrary.Data namespace, but I still get the error. Thanks. ...
8
5423
by: cd~ | last post by:
I can provide a test app, the news server won't allow me to post the files because they are too large (93KB and 1.2KB) I downloaded the ESRI ArcXml schema and generated the classes from the...
1
39662
by: Tim | last post by:
Could anyone tell me what this means and how do I correct it. Any suggestions? Thanks! Tim Richardson IT Developer and Consultant www.paladin3d.com Unable to serialize the session state. In...
4
7075
by: =?Utf-8?B?Qnlyb24=?= | last post by:
When I try to serialize an instance of the LocationCell below (note Building field) I get an error in the reflection attempt. If I remove the _Building field it serializes fine. I tried renaming...
9
1881
by: Gillard | last post by:
i get an exeption and i do not know what else to do to continue Dim sdf As New SaveFileDialog With sdf .AddExtension = True .DefaultExt = ".record" .FileName = Now.ToLongDateString .Filter =...
0
7174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7220
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...
1
6894
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...
0
7388
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...
0
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4600
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...
0
3099
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...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.