Hi to everyone here.
If I use DataSet.WriteXml(fileName) I get following error:
"An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll
Additional information: Token StartElement in state Epilog would result in an invalid XML document."
If I comment the last line of following code (ds.WriteXml(fName) everything is O.K. All data are in dataGrid.
If I try to write modified DataSet back to Xml file I get this error.
The main part of my code:
public Form1()
{
InitializeComponent();
string fName="myFile.xml";
DataSet ds= new DataSet();
DataTable tb;
DataRow rw;
ds.ReadXml(fName);
dataGrid1.DataSource=ds;
dataGrid1.DataMember="data";
tb=ds.Tables["data"];
rw=tb.NewRow();
rw[0]="blablabla";
rw[1]="oooooo";
rw[2]="coucou";
tb.Rows.Add(rw);
ds.WriteXml(fName);
}
Where is the problem ?
Lot of thanks for every answer....
J&M
If I use DataSet.WriteXml(fileName) I get following error:
"An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll
Additional information: Token StartElement in state Epilog would result in an invalid XML document."
If I comment the last line of following code (ds.WriteXml(fName) everything is O.K. All data are in dataGrid.
If I try to write modified DataSet back to Xml file I get this error.
The main part of my code:
public Form1()
{
InitializeComponent();
string fName="myFile.xml";
DataSet ds= new DataSet();
DataTable tb;
DataRow rw;
ds.ReadXml(fName);
dataGrid1.DataSource=ds;
dataGrid1.DataMember="data";
tb=ds.Tables["data"];
rw=tb.NewRow();
rw[0]="blablabla";
rw[1]="oooooo";
rw[2]="coucou";
tb.Rows.Add(rw);
ds.WriteXml(fName);
}
Where is the problem ?
Lot of thanks for every answer....
J&M