472,325 Members | 1,519 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,325 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 7357
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...
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...
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...
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...
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...
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...
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...
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...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.