I am trying get the changed values from the sqlserver using the server_broker feature.
my code is like below
protected void Page_Load(object sender,
For an ASP.NET application you have to use the SqlCacheDependency
class in name space System.Web.Caching
; so you don't need the OnChange
handler in this scenario.
This article explains how to implement SqlCacheDependency for an asp.net client:
Query Notification using SqlDependency and SqlCacheDependency
However, you have mentioned you are using SQL Server Express 2012 and according to page Features Supported by the Editions of SQL Server 2012 and similar case in older SQl Server Express edition Using Service Broker with Sql Server Express 2008, since the SQL Server 2012 Express does not support the broker service, you will be unable to perform Query Notification in SQL Server 2012 Express.
Edit: this paragraph is incorrect (reckon due to the MSDN page on which is based being misleading). Express editions support Service Broker and Query Notifications just fine, on all versions since SQL Server 2005. The 'Client Only' comment is better explained on the Express SQL Server Express Features page:
SQL Server Express supports Service Broker, but direct communication between two SQL Server Express servers is not supported.
this restrictions does not affect Query Notifications.
These references are now merely informational Detecting Changes with SqlDependency , Creating a Query Notification , SqlDependency in an ASP.NET Application.