Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Write Datatable data to XML string for database storage (.NET 1.1)

Posted on 2008-10-22
2
Medium Priority
?
376 Views
Last Modified: 2013-11-07
How can I write a datatable's content as an XML String for storing in a database? The only examples I found were for writing to an XML file.  
0
Comment
Question by:ZekeLA
2 Comments
 
LVL 48

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 22781491
Hi ZekeLA,

You'll need to write the XML to file, then read that file using a TextReader or something....

    Dim tmp As String = My.Computer.FileSystem.GetTempFileName
    YourDataSet.WriteXml(tmp)
    Dim xmlString As String = IO.File.ReadAllText(tmp)

Regards,

Wayne
0
 
LVL 1

Accepted Solution

by:
ZekeLA earned 0 total points
ID: 22909484
I didn't want to write to a file. Here is the solution I found from another site:

StringWriter stringWriter = new StringWriter();
dt.WriteXml(stringWriter, XmlWriteMode.WriteSchema);
string s = stringWriter.ToString();
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Loops Section Overview
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question