Posted on: 8/26/2014 7:22:44 PM | Views : 811

we know that when we work with sql dependency class then we need to work with OnChange event. OnChange event fire when data change occur in db table which is monitored.see my OnChange event code.
protected void Application_Start(Object sender, EventArgs e) { System.Data.SqlClient.SqlDependency.Start(connectionString); RegisterNotification(); } static SqlDependency dep; private static void RegisterNotification() { try { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT ID, Name FROM [bba-reman].TestTable"; dep = new SqlDependency(cmd); dep.OnChange += new OnChangeEventHandler(OnDataChange); ...

Go to the complete details ...