views:

18

answers:

2

I've got in-memory dataset with couple of tables that is populated in code. Data-bound grids on the gui show table contents without a problem.

Then I try to export the dataset into XML:

ds.WriteXml(fdSave.FileName, XmlWriteMode.WriteSchema);

and get empty XML (with couple of lines regarding dataset names but without any tables)

If I export table directly I've got all the data but dataset name is obviously wrong:

ds.Fields.WriteXml(fdSave.FileName, XmlWriteMode.WriteSchema);

What am I missing? Is there any reasonable way to write the whole dataset into file?

A: 

Have a look at the documentation on DataSet.WriteXml:

http://msdn.microsoft.com/en-us/library/ms135425.aspx

and on XmlWriteMode:

http://msdn.microsoft.com/en-us/library/system.data.xmlwritemode.aspx

Try using XmlWriteMode.IgnoreSchema. The docs say for XmlWriteMode.WriteSchema "If the DataSet does not have a current schema, nothing is written."

Jeff Schumacher
nope, IgnoreShema doesn't helpwhy wouldn't be any schema there if tables are defined in the dataset and can be saved by themselves?
Shaine
Have you tried WriteXml without the XmlWriteMode option, and just the filestream or filename?http://msdn.microsoft.com/en-us/library/hb27k0tf(v=VS.100).aspx
Jeff Schumacher
A: 

ok, silly me. was clearing dataset tables collection before populating it...

Shaine