Hello
i have developed c# application that connects to sql server
my sql server database contains about 20 tables.
a user(1) asks for table records , the application connects to the server and sql command is executed to fill the data into gridview
the problem is when another user(2) updated the same table that was required by user(1) , the changes wont reflect to user(1) gridview.
thanks for your reply in Advance.
What I have tried:
i have tried c# sqldependency class using service broker but that didn't much helped me out because sqldependency is used to monitor a single sql command
what i want is to monitor any changes happened to the table and notify all users to refresh there datasource and refill the datagridview
part of the code i used :
starting sql dependency :
SqlDependency depend = new SqlDependency(cmd);
depend.OnChange += new OnChangeEventHandler(OnDependencyChange);
cmd.Notification = null;
SqlDependency.Start(sqlcon.ConnectionString.ToString());
OnDependencyChange :
void OnDependencyChange(object sender, SqlNotificationEventArgs e)
{
SqlDependency dependency = sender as SqlDependency;
dependency.OnChange -= new OnChangeEventHandler(OnDependencyChange);
MessageBox.Show("table is altered");
}