且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

看在SQL数据库中的表的新记录

更新时间:2023-11-30 21:41:34

您可以使用SqlDependency类。其用途主要是为ASP.NET页面(低数量的客户端通知)。

You can use the SqlDependency Class. Its intended use is mostly for ASP.NET pages (low number of client notifications).

ALTER DATABASE UrDb SET ENABLE_BROKER

实施的OnChange 事件得到通知:

void OnChange(object sender, SqlNotificationEventArgs e)

和在code:

SqlCommand cmd = ...
cmd.Notification = null;

SqlDependency dependency = new SqlDependency(cmd);

dependency.OnChange += OnChange;

它使用的服务代理(一个基于消息的通信平台)从数据库引擎接收消息。

It uses the Service Broker (a message-based communication platform) to receive messages from the database engine.

您可能也想看看普通查询通知