DataSet updating on local LAN

Hi.
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.
LVL 1
MOH_RAsked:
Who is Participating?
 
jaynusConnect With a Mentor Commented:
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.
0
 
jaynusCommented:
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.
0
 
MOH_RAuthor Commented:
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.
0
All Courses

From novice to tech pro — start learning today.