Serialize a dataset

G

Guest

How do a serialize a dataset?
I tried
string buf;
buf = mydataset.GetXml();
I got the data but no Schema.
There is a GetXmlSchema, but I want everything together.
Can I append the dataset string to the schema string and get a complete
dataset?
 
M

Matt Noonan

This will give you the schema:

StringWriter writer = new StringWriter();
XmlSerializer ser = new XmlSerializer(typeof(DataSet));
ser.Serialize(writer, dataSet);
return writer.ToString();
 

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