开发者

Automatic update from database

开发者 https://www.devze.com 2023-03-10 02:18 出处:网络
I\'m developing in WPF and want my DataGrid to automaticall开发者_StackOverflow中文版y refresh when there\'s a change in the DB, and vice versa.

I'm developing in WPF and want my DataGrid to automaticall开发者_StackOverflow中文版y refresh when there's a change in the DB, and vice versa.

Today I'm using Timers and simple Selects to perform the updates. Is there something in .Net that provides that functionality ?


Unfortunately Database are "pull" data sources and doesn't provide any "Push" data model to make your code notify about the changes, until you implement pseudo push which is basically what you have mentioned i.e timers polling the database. Other option may be to implement a Trigger which calls a CLR SP and this SP is able to send the data to your code through remoting or something like that.


One idea is to use MSMQ. That way multiple client applications can get be notified whenever something changes. You need to add a trigger in your SQL database (or the application that is modifying the database) to notify the message queue whenever something new is added (see: Posting Message to MSMQ through SQL Server). Your client application would then need to subscribe to the Message Queue and would act on any new messages being posted there.

There is also SQL Server Service Broker but I am not really familiar with that, but might be worth investigating.


try to use SQL Server Notification Services. i didn't use it before but u can do that using it

0

精彩评论

暂无评论...
验证码 换一张
取 消