XML string from data

J

Joe Johnston

I want to create an XML string from data. I need to be able to store the
contents of the string in a database. Everything I have seen talks about
xml files... I don't want the IO I just want the data. So in a nutshell,
SQL statement or dataset to fully qualified XML string. And how would I
read that XML string into as dataset to bind to a control later?

Dim DS As DataSet
Dim MyConnection As New SqlConnection
Dim MyCommand As SqlDataAdapter
MyCommand = New SqlDataAdapter(strSQL, SqlCn)
DS = New DataSet("MyCartDS")
MyCommand.Fill(DS, "Cart") ' From here my DS is happy and busting at
the seams with data ..

My thanks in advance,
Joe Johnston
 
C

Cor

Hi Joe,

Maybe I dont understand you, but XML is not always a dataset, it is a format
that holds and describes data.

In .Net a dataset is always convertable to an XML file using
"dataset.writeXML", but with that not every XML file a dataset.

If you want to import data from an XML file in a database that supports XML
datasets, you have first to make that dataset in the proper dataset XML
format.

You can read XML files (including datasets) in a lot of ways.

By instance using loadXML (the DOM method) or the XMLreader.

I hope this helps a little bit?

Cor
 
G

Guest

For the lurkers:

The perfect concise answer came from a wonderfull woman in Washington State,
Bonnie Berent:

In order to get the complete XML string, or what would be the contents of
our overpopular .xml files use:
DS.GetXML()

To read an XML string into a DataSet, do something like this:
Dim sr As StringReader = new StringReader(XML
DS.ReadXML(sr, XmlReadMode.InferSchema)

Joe Johnston
www.gotboxer.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top