This topic has not yet been rated - Rate this topic

SqlDependency.OnChange Event

Occurs when a notification is received for any of the commands associated with this SqlDependency object.

Namespace:  System.Data.SqlClient
Assembly:  System.Data (in System.Data.dll)
public event OnChangeEventHandler OnChange

OnChange occurs when the results for the associated command change. If you are not using OnChange, you can check the HasChanges property to determine whether the query results have changed.

The OnChange event does not necessarily imply a change in the data. Other circumstances, such as time-out expired and failure to set the notification request, also generate OnChange.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Specific SQL Role name required for functionality
If the SQL user account connecting from your application to your database is not a db_owner then you must:
1. Create a SQL role with the name 'sql_dependency_subscriber'. It must have that name as that string is hard coded into the .NET framework.
2. Assign your SQL user account to this role.