Groups | Blog | Home
all groups > dotnet xml > april 2006 >

dotnet xml : NewDataSet root element annoyance



Michael Kolias
4/13/2006 3:19:35 PM
How can I change the root element of a dataset written to an xml file.
Even though I specify the name of the dataset both in the constructor and by
calling its property
the root element of the xml file is always 'NewDataSet'

Any help would appreciated.

**************************************************
I have the following code:

oDs = new DataSet("ErrorLog");
oDs.DataSetName = "ErrorLog";
oDs.ReadXmlSchema(m_SchemaFile);

.Adding some rows to the dataset
.

oDs.WriteXml(m_LogFile);


dickster
4/14/2006 4:51:06 AM
Michael

I believe that your call to:
-------------------------------------------------------------
oDs.ReadXmlSchema(m_SchemaFile);
-------------------------------------------------------------
overrides the value set in your previous line of code
i.e. oDs.DataSetName = "ErrorLog";

So switch your code round to the following:
-------------------------------------------------------------
oDs = new DataSet();
oDs.ReadXmlSchema(m_SchemaFile);
oDs.DataSetName = "ErrorLog";
-------------------------------------------------------------


Dickster
Michael Kolias
4/14/2006 5:08:40 PM
That one did the trick.
Thanx a lot Dickster !!!

[quoted text, click to view]

AddThis Social Bookmark Button