Hi!
I'm trying to add new rows to an .xml file using a 'typed dataset'.
The code I'm presently using to add the entries is as follows:
string[] strArray = new string[9]
{
txtID.Text, txtName.Text //These are fields on a UserForm
};
DataRow row = register1.Student.NewRow(); //register1 is my DataSet
for (int i = 0; i
row[i] = strArray[i];
}
register1.Student.Rows.Add(row);
register1.WriteXml(<
Although this code will add rows to my .xml file, I end up with the new information in the wrong place.
For example, let's assume that I want to add "
At the moment, I get: -
...when what I actually want is: -
Notice how the rows marked 'Student' are INSIDE the '
Does anybody out there have any idea what I might be doing wrong?
Any help would be greatly appreciated!!
MattPosted Jul 18, 2005, 8:17 AM
I'll give that a try.
Mahesh ChandPosted Jul 14, 2005, 9:51 AM
I did not look at the code you had above but you can do this:
Psuedo Code:
DataRow row = DataSet.Tables["TableName"].Rows.AddNew();
row["ColumnName] = "Value";
// Add other column values here
row.Update() OR row.AcceptChanges() or something.
// Repeat rows if they are more than one here.
This will add a new row to your DataSet's Table.
Now use DataSet.Save /WriteXml methods.