W
Walt Borders
Hi
I am new to xml and handling data in xml format.
I am able to read an XML file and schema into a DataGrid.
I can display the columns and values correctly using the
DataGridColumnStyle.
The problem is that when I write the dataSet to a file the nested
relation data does not nest correctly.
I've tried setting the relationship explicitly on the implicit
"tablename_id" column, but I receive an error telling me that a
relationship already exists.
I've dropped the relationship and added the new and receive a run-time
error: "A column name 'Rule' already belongs to this DataTable: cannot
set a nested table name to the same name.
There is a child table named "Rule". It is the child of a table name
"RuleList". There is no column named "Rule" in the DataSet.
At MSDN, and reading the "Nested DataRelations" in particular, it
seems that all I have to do is set NESTED = TRUE. Easier read than
done.
Any help/examples/correction will be very helpful.
Walt Borders
Code Snippets.
myDataSet = new DataSet();
myDataSet.ReadXmlSchema("ConfigSystem.xsd");
myDataSet.ReadXml("ConfigSystem.xml", XmlReadMode.ReadSchema);
this.dataGrid1.SetDataBinding(this.myDataSet,"Rule");
/// Display dataGrid1
/// Push button to Write the file
this.myDataSet.AcceptChanges();
// Re-Write the original file
string filename = "ConfigSystem.xml";
// Create the FileStream to write with.
System.IO.FileStream myFileStream = new System.IO.FileStream(filename,
System.IO.FileMode.Create);
// Create an XmlTextWriter with the fileStream.
System.Xml.XmlTextWriter myXmlWriter = new
System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
myXmlWriter.Formatting = Formatting.Indented;
myXmlWriter.Indentation = 3;
// Write to the file with the WriteXml method.
thisDataSet.WriteXml(myXmlWriter, XmlWriteMode.WriteSchema);
/// Done
I am new to xml and handling data in xml format.
I am able to read an XML file and schema into a DataGrid.
I can display the columns and values correctly using the
DataGridColumnStyle.
The problem is that when I write the dataSet to a file the nested
relation data does not nest correctly.
I've tried setting the relationship explicitly on the implicit
"tablename_id" column, but I receive an error telling me that a
relationship already exists.
I've dropped the relationship and added the new and receive a run-time
error: "A column name 'Rule' already belongs to this DataTable: cannot
set a nested table name to the same name.
There is a child table named "Rule". It is the child of a table name
"RuleList". There is no column named "Rule" in the DataSet.
At MSDN, and reading the "Nested DataRelations" in particular, it
seems that all I have to do is set NESTED = TRUE. Easier read than
done.
Any help/examples/correction will be very helpful.
Walt Borders
Code Snippets.
myDataSet = new DataSet();
myDataSet.ReadXmlSchema("ConfigSystem.xsd");
myDataSet.ReadXml("ConfigSystem.xml", XmlReadMode.ReadSchema);
this.dataGrid1.SetDataBinding(this.myDataSet,"Rule");
/// Display dataGrid1
/// Push button to Write the file
this.myDataSet.AcceptChanges();
// Re-Write the original file
string filename = "ConfigSystem.xml";
// Create the FileStream to write with.
System.IO.FileStream myFileStream = new System.IO.FileStream(filename,
System.IO.FileMode.Create);
// Create an XmlTextWriter with the fileStream.
System.Xml.XmlTextWriter myXmlWriter = new
System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
myXmlWriter.Formatting = Formatting.Indented;
myXmlWriter.Indentation = 3;
// Write to the file with the WriteXml method.
thisDataSet.WriteXml(myXmlWriter, XmlWriteMode.WriteSchema);
/// Done