473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Novice: Concurrent access to XML File

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

Nov 11 '05 #1
2 7446
Ted,

an XML file is not a good data store in a multiuser scenario, but you
already found that out by yourself. The best advice I can give you is to not
use an XML file as a data store.

To work around this problem you'd face writing an abstraction layer that
hides the data store, and knows how to resolve conflicts based on an
optimistic locking strategy - e.g. you include a unique identifier and a
timestamp on every record, detect any update conflicts and reject the
update. Still, you can't work around the fact that you have to completely
lock the entire file while an update is in progress. This can severly impact
performance and scalability of your app.

A better solution is to store data in a data store that providers finer
grained data access, such as a database. There are plenty of cheap solutions
out there that work in low volume scenarios. The Microsoft way would be
MSDE, which is a free, scaled down version of SQL Server that works
seemlessly with the .NET Framework and SQLXML.

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET

"Ted Duross" <te*******@RogersNoSpam.com> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
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

Nov 11 '05 #2
Dear Christoph,

Thank you very much for this information. I've started to read up on
MSDE and am quite excited by the options it provides (not to mention the
price).

Before this I had been considering another approach. My application
will likely be used by quite a small group at any one time, 20 to 30 max.
Actual writing to the XML file would be as the app closed. I was considering
making use of the FileStream's Lock method to block access to my XML file
while data was being updated. If another instance of the app attempted to
access the file when locked it would place itself into a repeat loop,
reattempting access every few seconds until successful.

Thanks again,
Ted
"Christoph" <ch*************@austin.rr.com> wrote in message
news:uy**************@TK2MSFTNGP11.phx.gbl...
Ted,

an XML file is not a good data store in a multiuser scenario, but you
already found that out by yourself. The best advice I can give you is to not use an XML file as a data store.

To work around this problem you'd face writing an abstraction layer that
hides the data store, and knows how to resolve conflicts based on an
optimistic locking strategy - e.g. you include a unique identifier and a
timestamp on every record, detect any update conflicts and reject the
update. Still, you can't work around the fact that you have to completely
lock the entire file while an update is in progress. This can severly impact performance and scalability of your app.

A better solution is to store data in a data store that providers finer
grained data access, such as a database. There are plenty of cheap solutions out there that work in low volume scenarios. The Microsoft way would be
MSDE, which is a free, scaled down version of SQL Server that works
seemlessly with the .NET Framework and SQLXML.

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET

"Ted Duross" <te*******@RogersNoSpam.com> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
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


Nov 11 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: CJM | last post by:
I'm setting up some web-based (ASP) reports that query an Access DB. I also want certain people to be able to access and manipulate the database directly. However, if the database is open in...
11
by: Durai | last post by:
Hi All, I tested "concurrent testing" in MySQL. It works fine. But I couldn't do in PostgreSQL 7.3.4 on HPUX IPF. I got deadlock problem. I used the PHP script to update table( one script...
1
by: bluedolphin | last post by:
There seems to be a consensus that Access has a concurrent user limit of 200 users. I am working on a system that currently stands at approx. 1 gig and has a small number of users. However, there...
3
by: mgPA | last post by:
Short: How can I limit the number of concurrent logins to Access (2000) DB? Long: I seem to be having the problem discussed in previous postings of having more than 9 or 10 concurrent logins. ...
4
by: trond | last post by:
Hello all, Before I start I'd like to point out that I am a complete novice when it comes to asp.net - My background is in network and operating systems, and although I have been doing a bit of...
5
by: sethwai | last post by:
Hi, I've read everything I can get my hands on and am still very confused about the similarities and differences between db2_mmap_read/write and concurrent i/o. It seems to me at this point...
6
by: roblugt | last post by:
I have what I imagine is a well-known .Net networking problem, but even though I've Googled for some time I've not yet come across a thread where this has been fully explained... There is a...
6
by: goraya | last post by:
This is design level discussion about web applications. How I design application that support 1 million concurrent requests??
0
amitpatel66
by: amitpatel66 | last post by:
There is always a requirement that in Oracle Applications, the Concurrent Program need to be execute programatically based on certain conditions/validations: Concurrent programs can be executed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.