且构网

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

数据库中的数据更改时自动更新UI.

更新时间:2023-02-08 17:34:30

IIRC,您需要SQL通知服务.

实施SQL通知 [
IIRC you need SQL Notification service.

Implementing SQL Notification[^]


是否具有此功能取决于您正在使用的数据库引擎. Notification Server已从SQL Server 2008中删除.

首先,其他引擎从未具有通知服务的优势.

另一种选择是在数据库之上编写一个层,客户可以使用该层从数据库获取数据或向数据库写入数据.此层还将具有您的客户端订阅的机制,因此,当该层将数据写入数据库时​​,该层将向客户端发送通知.编写起来并不容易,但是使用Windows Communication Foundation会更容易.
If you even have this capability depends on the database engine you''re using. Notification Servers was removed from SQL Server 2008.

Other engines never had the equivilient of notification services in the first place.

Another option would be to write a layer on top of your database that your clients use to get/write data from/to the database. This layer would also have a mechanism that your clients subscribe to so when the layer writes data to the database, the layer would send a notification to the clients. This is NOT easy to write, but would be made easier with Windows Communication Foundation.