Monitoring data change using SqlDependency and C#
What is SqlDependency? As the word describes itself, it is used to notify your application or user when certain criteria or condition is satisfied. This condition (query in technical terms) is provided to SQL notification service to be observed upon and ask to be notified when the condition is met or the data changes. In short the SqlDependency provides capabilities to your application to monitor your database for data change without the hassles of continuously querying the database using timers or loops. I will walk you through the simplest way to enable SqlDependency in your application. For the purpose of this example I am using SQL Server 2012 Express, it also works for other versions of SQL database like SQL 2008 and 2005. The part of SQL Server that make things happen: SQL Server – SQL Service Broker and Queues. SQL Service broker (Ref: MSDN) – It is a feature of SQL » Read more