473,395 Members | 1,720 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,395 software developers and data experts.

DataTable

Hi!

I need save data from DataTable to XML file. Is there any standard method do
that?

Thanks a lot
Nov 17 '05 #1
8 7717
You can save all DataSet on XML File.

Dataset.WriteXml() ;

i hope it will be usefull for you.

Bruno Spinelli

"Aleksey" wrote:
Hi!

I need save data from DataTable to XML file. Is there any standard method do
that?

Thanks a lot

Nov 17 '05 #2
myDataStore.WriteXml(FullPath,XmlWriteMode.WriteSc hema);
Nov 17 '05 #3
In message <eL**************@TK2MSFTNGP12.phx.gbl>, Aleksey
<al************@il.quest.com> writes
Hi!

I need save data from DataTable to XML file. Is there any standard method do
that?


You can pass a dataset into the constructor of an XmlDataDocument. You
can then use the Save method of the XmlDataDocument. If you don't
already have it, you can get the dataset the table belongs to from the
DataSet property.

--
Steve Walker
Nov 17 '05 #4
Hi,

I need convert data from DataTable to XML file. Understand that I can use
the following command to do it. However, there will be existing file be
created. Is there any other ways which there wont be file created? I only
need to store it in memory.
Thanks.

Cheers,
Siew Yee

"Bruno Spinelli" wrote:
You can save all DataSet on XML File.

Dataset.WriteXml() ;

i hope it will be usefull for you.

Bruno Spinelli

"Aleksey" wrote:
Hi!

I need save data from DataTable to XML file. Is there any standard method do
that?

Thanks a lot

Nov 17 '05 #5
This isn't exact since I'm doing it from memory, but it goes something
like this.

dim MS as new system.io.memorystream
Ds.WriteXML(MS)

Something close to that.
Chris

Siew Yee wrote:
Hi,

I need convert data from DataTable to XML file. Understand that I can use
the following command to do it. However, there will be existing file be
created. Is there any other ways which there wont be file created? I only
need to store it in memory.
Thanks.

Cheers,
Siew Yee

"Bruno Spinelli" wrote:

You can save all DataSet on XML File.

Dataset.WriteXml() ;

i hope it will be usefull for you.

Bruno Spinelli

"Aleksey" wrote:

Hi!

I need save data from DataTable to XML file. Is there any standard method do
that?

Thanks a lot

Nov 17 '05 #6
<"=?Utf-8?B?U2lldyBZZWU=?=" <Siew Ye*@discussions.microsoft.com>>
wrote:
I need convert data from DataTable to XML file. Understand that I can use
the following command to do it. However, there will be existing file be
created. Is there any other ways which there wont be file created? I only
need to store it in memory.


DataSet.WriteXml can write to a stream, a TextWriter, an XmlWriter or a
file. You could use a MemoryStream, a StringWriter, or an XmlWriter
backed by either of them.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #7
You could use XMLSerializer, and MemoryStream. As Follows(Replace Insect by
DataTable and Stream by MemoryStream):

Insect i = new Insect("Meadow Brown", 12);
XmlSerializer x = new XmlSerializer(typeof(Insect));
Stream s = File.Create("AnInsect.xml");
x.Serialize(s,i);


"Siew Yee" <Siew Ye*@discussions.microsoft.com> дÈëÏûÏ¢ÐÂÎÅ
:6E**********************************@microsoft.co m...
Hi,

I need convert data from DataTable to XML file. Understand that I can use
the following command to do it. However, there will be existing file be
created. Is there any other ways which there wont be file created? I only
need to store it in memory.
Thanks.

Cheers,
Siew Yee

"Bruno Spinelli" wrote:
You can save all DataSet on XML File.

Dataset.WriteXml() ;

i hope it will be usefull for you.

Bruno Spinelli

"Aleksey" wrote:
Hi!

I need save data from DataTable to XML file. Is there any standard method do that?

Thanks a lot

Nov 17 '05 #8
Thanks all for the information.

Below are my original codes that will create the xml file physically:

private void convertDataTableToXML()
{
// Duplicate the table and add it to a temporary DataSet
DataSet dataset = new DataSet();
DataTable datatable = premiumTable.Copy();
dataset.Tables.Add(datatable);

// Save the temporary DataSet to XML
StreamWriter streamwriter = new StreamWriter("C://XMLDoc.xml");
dataset.WriteXml(streamwriter);
streamwriter.Close();
}

However, instead of using StreamWriter, I change to MemoryStream.
Below is the codes:

MemoryStream ms = new MemoryStream();
dataset.WriteXml(ms);
ms.Close();

How to I reference the xml file created by MemoryStream for later use? Eg, I
need to extract a node value from the xml file.
Thanks.

Thanks,
Siew Yee

"Jon Skeet [C# MVP]" wrote:
<"=?Utf-8?B?U2lldyBZZWU=?=" <Siew Ye*@discussions.microsoft.com>>
wrote:
I need convert data from DataTable to XML file. Understand that I can use
the following command to do it. However, there will be existing file be
created. Is there any other ways which there wont be file created? I only
need to store it in memory.


DataSet.WriteXml can write to a stream, a TextWriter, an XmlWriter or a
file. You could use a MemoryStream, a StringWriter, or an XmlWriter
backed by either of them.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #9

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

Similar topics

5
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the...
5
by: Stefan Turalski \(stic\) | last post by:
Hi, I'm wondering if there is a way to send a method parametrs by ref when DataTabel is a type of this value ? I done some sort of select over DataTable columns, just by removing them froma...
1
by: TaeHo Yoo | last post by:
Hi all, After sorting and grouping data using a dataview, then how to transfer the changed datatable in the dataview to a datatable in C#? Cheers
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
7
by: Raymond Lewallen | last post by:
Which would be the proper way or the reason for using any of the following or combinations of the following? These are the 3 ways I've figured I can do what I want to do, I just don't know which...
3
by: Gene Hubert | last post by:
I'm using DataTable.ImportRow to move data from one datatable to another... Dim dt, dtTarget As DataTable Dim dr As DataRow dt = DirectCast(Me.DataSource, DataTable) dtTarget = dt.Clone...
3
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something...
6
by: Pete Wittig | last post by:
Hi, I have a DataTable and I want to get a subset of the rows within it. I use the Select method to get my subset and the results are in a DataRow. I want to put those Rows back into a...
0
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: ...
5
by: Frank Hauptlorenz | last post by:
Hello, I recognized some days ago, that returning a DataTable blocks my WCF-Service. Is this a known bug? If I add this table to a new DataSet() and return this, it works. Thank you, Frank
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...

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.