Hi,
I’ve created an educational software application accessed by students from a
central server. On Start-Up the application reads an XML file that stores
student progress records. This XML file stores DataSet information, one
DataTable and a number of DataRows, one per student. Once finished the
student’s DataRow is updated and the DataSet is written to the XML file.
My problem is that during the time the student has worked on the application
other students will have written to the XML file, updating their progress
information. The student’s copy of the DataSet is no longer current. Writing
to the XML file will write over data entered by other students.
Is there an effective way, at Close, to reread the XML file into the App,
update the current student’s DataRow, and then immediately write back to the
XML file. Basically I am looking for a way to lock up access to the XML file
during this process. My present Load and Closing code includes:
// On Opening
DataSet ds;
{
XmlDataDocument doc = new XmlDataDocument();
doc.DataSet.ReadXml("convowel.xml");
ds = new DataSet("TargetLetters");
ds = doc.DataSet;
}
// On Closing
private void ConVowelDialog_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
StreamWriter myStreamWriter = new
StreamWriter(@"convowel.xml");
ds.WriteXml(myStreamWriter);
myStreamWriter.Close();
}
Any advice would be greatly appreciated.
Ted