473,804 Members | 3,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The Problem of WriteXml

ad
I test the XmlWrite/XmlRead from MemoryStrem, my codes is:

DataSet ds = Will.DM.Execute Dataset("Select * from Customer);
MemoryStream msOri = new MemoryStream();
ds.WriteXml(msO ri);

DataSet ds2 = new DataSet();
ds2.ReadXml(msO ri);

It compiled ok, but when it run fail at the last line: ds.WriteXml(msO ri);
Ther error message is
System.Xml.XmlE xception: Root element is missing.

The msOri is write form ds, why it can't read to ds2?
Nov 17 '05 #1
3 4306
The reason is because the pointer in the stream is at the end of the
stream.

You need to reset the position to the beginning of the stream. Before
the call to ReadXml, do this:

// Set the position in the stream to the beginning.
msOri.Position = 0;

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"ad" <fl****@wfes.tc c.edu.tw> wrote in message
news:Od******** *****@TK2MSFTNG P12.phx.gbl...
I test the XmlWrite/XmlRead from MemoryStrem, my codes is:

DataSet ds = Will.DM.Execute Dataset("Select * from Customer);
MemoryStream msOri = new MemoryStream();
ds.WriteXml(msO ri);

DataSet ds2 = new DataSet();
ds2.ReadXml(msO ri);

It compiled ok, but when it run fail at the last line:
ds.WriteXml(msO ri);
Ther error message is
System.Xml.XmlE xception: Root element is missing.

The msOri is write form ds, why it can't read to ds2?

Nov 17 '05 #2
VJ
ds.WriteXml(msO ri, XmlWriteMode.Wr iteSchema);

Schema.. has to be saved.. if you want to read back to a DataSet...

"ad" <fl****@wfes.tc c.edu.tw> wrote in message
news:Od******** *****@TK2MSFTNG P12.phx.gbl...
I test the XmlWrite/XmlRead from MemoryStrem, my codes is:

DataSet ds = Will.DM.Execute Dataset("Select * from Customer);
MemoryStream msOri = new MemoryStream();
ds.WriteXml(msO ri);
DataSet ds2 = new DataSet();
ds2.ReadXml(msO ri);

It compiled ok, but when it run fail at the last line:
ds.WriteXml(msO ri);
Ther error message is
System.Xml.XmlE xception: Root element is missing.

The msOri is write form ds, why it can't read to ds2?

Nov 17 '05 #3
ad
Thanks, You give me a great help!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> ¼¶¼g©ó¶l¥ó·s»D: Oz************* *@TK2MSFTNGP09. phx.gbl...
The reason is because the pointer in the stream is at the end of the
stream.

You need to reset the position to the beginning of the stream. Before
the call to ReadXml, do this:

// Set the position in the stream to the beginning.
msOri.Position = 0;

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"ad" <fl****@wfes.tc c.edu.tw> wrote in message
news:Od******** *****@TK2MSFTNG P12.phx.gbl...
I test the XmlWrite/XmlRead from MemoryStrem, my codes is:

DataSet ds = Will.DM.Execute Dataset("Select * from Customer);
MemoryStream msOri = new MemoryStream();
ds.WriteXml(msO ri);

DataSet ds2 = new DataSet();
ds2.ReadXml(msO ri);

It compiled ok, but when it run fail at the last line:
ds.WriteXml(msO ri);
Ther error message is
System.Xml.XmlE xception: Root element is missing.

The msOri is write form ds, why it can't read to ds2?


Nov 17 '05 #4

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

Similar topics

11
408
by: DraguVaso | last post by:
Hi, I should use XML to synchronize the data from different (VB.NET) applications, and I was just wondering which Overloads of these functions ( ReadXmlSchema, ReadXml and WriteXml) goes the fastest? I don't think the ReadXMLSchema would give a lot of difference, but maybe the overlaods of ReadXml and WriteXml will. Especially with larges files/datatables... Should I use the IO.Stream? The XmlReader/XmlWriter?
1
2357
by: Rahul Agarwal | last post by:
Hi I am trying to write data back to the client using dataset.WriteXML and I have set the Thread.CurrentThread.CurrentCulture to "no" (norwegian) just before writing the data using WriteXML. But dataset.WriteXML dosent seems to be using the CurrentCulture settings and still writes dates, numeric values using the original settings. My Code...
2
26737
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as empty elements in the XML. How to do that ? I don't understand why there is no simple option to specify the output format, or did I miss something ? regards andreas
1
5716
by: Greg R | last post by:
mydataset.WriteXml(strPath + "/my.xml"); produces this error [ArgumentException: URI formats are not supported. System.IO.Path.GetFullPathInternal(String path) +27 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) +23 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +4...
3
4830
by: Gordon Moore | last post by:
Hi, I'm new to using xml/xslt and although I can create an xml document using the dataset.WriteXml statement, and I have created an xslt to transform the xml into the output I want, I have to manually add the xsl reference statement to the xml file. i.e. <?xml version="1.0" standalone="yes"?> <?xml:stylesheet type="text/xsl" href="Questions.xsl"?> --> I have to
2
2511
by: Paolo Pignatelli | last post by:
I am trying to get an output/file like this (below) in an XML file (MyXmlFile.xml) (which I will use for a slide show) -- <gallery timer="3" order="sequential" fadetime="2" looping="yes" xpos="0" ypos="0"> <image path="images2/Test1.jpg" />
1
1383
by: Jacky | last post by:
hello i have to know if the writeXML process is a blocking process. Other mean if i write doc.WriteXML(); int i = 0; Is i = 0 can be executed before doc.WriteXML() method ended???? All this when the data we have to save can need up to 2 3 seconds. I think it's not blocking according to what I see in my application.
4
2406
by: Wes | last post by:
Hello, I have an application using an xml dataset to store app and user settings. The problem I am having is related to writexml. I have a save button on my application that updates the dataset and then using the writexml(...) function saves the dataset to an xml file. I have noticed that the file does not change everytime I click the save button. I get no errors but the writexml function does not seem to be updating the xml file. ...
2
1457
by: Guoqi Zheng | last post by:
Dear sir, I am trying to create to writeXml to create a xml file every day. The WriteXml method of dataset is very nice and easy to use, however, how can I add the following to my xml file? <?xml version="1.0" encoding="UTF-8"?> <productFeed version="0" timestamp="20040105:22:00:05">
2
1690
by: Tony Johansson | last post by:
Hello! Assume the following : 1. I create a DataSet with some DataRelation. 2. I then use WriteXml to write the DataSet to an Xml document using DataRelation.Nested = True 3.I then read the Xml document using ReadXml to load and create a DataSet. Now to my question is this DataSet that was created from 3 the same DataSet with the same structure
0
9706
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10571
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10075
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
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 we have to send another system

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.