DataSet updating on local LAN

Posted on 2005-03-08
Medium Priority
Last Modified: 2010-04-16
Suppose I have a local LAN with one server and 2 clients,
and SQL Server 2000 has been installed on server.
there is one table that each of 2 clients can update it.

my question is, if one client update that table, how another
client can find out that it should update its DataSet to view that changes.

(periodically updating the DataSet is a inefficient solution)
Thank you.
Question by:MOH_R
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 13497494
Heres one approach:
Create a Timer object (System.Windows.Forms.Timer) and 2 Datasets. 1 Dataset that your grid displays, another for caching. On each Timer.Tick, update your cache Dataset, and then do ViewDataSet.GetChanges() to see if there are updates, if there are, replicate them to the viewable dataset and refresh your dataGrid. It would be something like this.  

System.Windows.Forms.Timer timer;
System.Windows.Forms.DataGrid dataGrid;
System.Data.DataSet viewSet, cacheSet;

constructor() {
   ......Pull Data into viewSet .....
  dataGrid.DataSource = viewSet;
  this.Ticker.Interval = 5000; // 5 Seconds
  this.Ticker.Tick += new EventHandler(this.Ticker);

private void Ticker(object sender, System.EventArgs e){
   ....Pull Data into cacheSet......
   if((viewSet.GetChanges(cacheSet)) != null) {  // The magical check.
       viewSet = cacheSet;
       dataGrid.Refresh(); // Otherwise your dataGrid wont update.

To prevent from having to pull alllllll those records, what you might want to do is expand this a bit with a DateTime field in the db and a WHERE call for the past x time (for your Ticker). I think sqlDataAdapter also has a mapping method with updating, but Ive never touched it so I wont try to pretend like I know what Im talking about.

Author Comment

ID: 13505387
Dear jaynus.

my question was if the physical table update by another
user how I can find this matter.
dose sql server have a message or interrupt for updating to all users of that table ?

Thank you.

Accepted Solution

jaynus earned 500 total points
ID: 13507849
No, SQL does not.  The tables arn't cached in any manner except on the receiving data connectors end.  When a table is pulled, its passed to the user application via whatever manner, and then that is it.  An update within sql would not effect anything, being the table is already cached with the user.

The only real way to 'watch for updates' is to actually watch for them, being there is no automated way to watch it.  The only way to make this perform better would be to have a stored procedure that somehow checks for last changes and such.

*True* Real-time update monitoring is really in impossible solution when it comes to data access, unless you setup some sort of monitoring that does 50ms checks or something of the sort.  

That being said, that is why I have suggested some sort of 1-5sec check and update.  Its the most efficient solution you'll find programmatically, and the only real forseeable performance improvement that can be made upon it is creating some sort of true/false date-based update check prior to pulling all the new records (which I highly recommend and can give examples of if you like).

Another possible work-around for this would be an update-index table, that index's table names and dates of updates, and have all your stored procedures that edit the table, post to the update index accordingly.

But anyways, back to the point.  SQL Data Access is all cache based on the clients connector end, and recursive checks is the best (and most feasible) way to monitor updates.  If you would like some examples of programmatic update-checks or sql-based stored procedures that would return-true false, I can provide them.  I have alot of applications built around this sort of time-sensitive issue.

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question