WriteXML and ReadXML For Datatable

Giganews Newsgroups
Subject: WriteXML and ReadXML For Datatable
Posted by:  Lee (L…@discussions.microsoft.com)
Date: Thu, 21 Aug 2008

Not sure why this does not work
Dim dt as new DataTable("settings")
...
dt.WriteXML(sFileName)
...
dt = new DataTable("settings")
dt.ReadXML(sFileName)

<CRASH> "DataTable does not support schema inference from Xml."
According to the documentation...
The ReadXml method provides a way to read either data only, or both data and
schema into a DataSet from an XML document, whereas the ReadXmlSchema method
reads only the schema. To read both data and schema, use one of the ReadXML
overloads that include the XmlReadMode parameter, and set its value to
ReadSchema.

Note that the same is true for the WriteXml and WriteXmlSchema methods,
respectively. To write XML data, or both schema and data from the DataTable,
use the WriteXml method. To write just the schema, use the WriteXmlSchema
method.

Replies