By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,317 Members | 2,352 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,317 IT Pros & Developers. It's quick & easy.

Empty Dataset Tables Don't Save to XML

P: n/a
How do you get around the problem of empty tables in a dataset not being
included when you do a WriteXML? When you later read the data back into a
new dataset, those tables are gone, because they never got saved to the XML
file. Only tables containing one or more records get saved to the XML file.
Thanks.
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I would get around this problem by programatically inserting a fake record
into the tables, then saving the xml, and then just don't save the fake
data.

"Phil Galey" <pa*****@starcalif.com.nospam> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
How do you get around the problem of empty tables in a dataset not being
included when you do a WriteXML? When you later read the data back into a
new dataset, those tables are gone, because they never got saved to the
XML
file. Only tables containing one or more records get saved to the XML
file.
Thanks.

Nov 12 '05 #2

P: n/a
"Phil Galey" <pa*****@starcalif.com.nospam> wrote in message news:%2***************@TK2MSFTNGP15.phx.gbl...
How do you get around the problem of empty tables in a dataset not being
included when you do a WriteXML? When you later read the data back into a
new dataset, those tables are gone


Use one of the WriteXml( ) method overloads that takes an XmlWriteMode,
specifying XmlWriteMode.WriteSchema:

dataSet1.WriteXml( writer, XmlWriteMode.WriteSchema);

Realize that when there is no data, it can't write content (any content it wrote
would be mistaken for a row of null values, making the DataTable non-empty.)
The only information of value to be persisted is the empty DataTable's schema.

Additionally, ensure the XmlReadMode on ReadXml( ) is Auto or ReadSchema,
and that the MissingSchemaAction on the DataAdapter is Add when rehydrating
the DataSet. (These settings are the defaults.)
Derek Harmon
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.