Showing posts with label dataset. Show all posts
Showing posts with label dataset. Show all posts

Thursday, October 1, 2009

Write Dataset to XML with WriteSchema

Serializing dataset ignores empty datatables

When you call lDataSet.WriteXml(aXMLFilePath), any data table without rows will be ignored. To include it (because table schema may still be important), use the WriteXml overload that writes to an xmlWriter and enable"WriteSchema".

I use XDocument that can create XmlWriter but I'm sure there are other ways.

XDocument lXDocument = new XDocument();
using (XmlWriter lXmlWriter = lXDocument.CreateWriter())
{
lMasterDataSet.WriteXml(lXmlWriter, XmlWriteMode.WriteSchema);
}
lXDocument.Save(@"c:\temp\PSReportServer_MasterDataSetWithSchema.xml");




Tuesday, July 14, 2009

DataSet Related

Copying a datatable
===============
When trying to add a datatable to a dataset and you get an error saying datatable belongs to another dataset, then do this: Set a new copieddatatable = origdatatable.copy(). You should be able to add the new copieddatatable to the dataset.