SqlDependency.OnChange Event


当收到与此 SqlDependency 对象关联的任意命令的通知时发生。Occurs when a notification is received for any of the commands associated with this SqlDependency object.

 event System::Data::SqlClient::OnChangeEventHandler ^ OnChange;
public event System.Data.SqlClient.OnChangeEventHandler OnChange;
member this.OnChange : System.Data.SqlClient.OnChangeEventHandler 
Public Custom Event OnChange As OnChangeEventHandler 


当关联命令的结果更改时发生 OnChangeOnChange occurs when the results for the associated command change. 如果不使用 OnChange,则可以检查 HasChanges 属性以确定查询结果是否已更改。If you are not using OnChange, you can check the HasChanges property to determine whether the query results have changed.

OnChange 事件并不一定意味着数据发生更改。The OnChange event does not necessarily imply a change in the data. 其他情况(如超时过期和设置通知请求失败)还会生成 OnChangeOther circumstances, such as time-out expired and failure to set the notification request, also generate OnChange.

Applies to

See also