473,320 Members | 2,145 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.

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 7709
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: 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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
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
1
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....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.