Link to home
Start Free TrialLog in
Avatar of MOH_R
MOH_R

asked on

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.
Avatar of jaynus
jaynus

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.
Avatar of MOH_R

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of jaynus
jaynus

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial