数据库更新托盘通知
我想构建一个小应用程序,每当更新或插入 SQL Server 数据库中的某个表时,它都会弹出托盘通知(或 Toast 弹出窗口或其他内容)。
如果可能的话,我想避免轮询,那么最简单的方法是什么?
i want to build a little app that pops up a tray notification (or a toast popup or something) whenever an update or insert going into a certain table in a SQL server database.
What is the simplest way of doing this as i want to avoid polling if possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查询通知。这是 SQL Server 的功能,允许应用程序在数据更改时订阅从服务器推送的通知。它通常通过 SqlDependency 类来利用。
我最近发布了 LinqToCache 项目允许您向 LINQ 查询添加基于 SqlDependency 的通知和缓存失效:
Query Notifications. This is the SQL Server feature that allows an application to subscribe to notifications pushed from the server when data is changed. It is usually leveraged through the SqlDependency class.
I have recently posted the LinqToCache project that allows you to add SqlDependency based notifications and cache invalidation to LINQ queries:
扩展存储过程也是我首先想到的,如果我想在 SQL Server 本身上运行监控应用程序,这可能是我会使用的解决方案。但我猜情况可能并非如此。
我本人建议使用 MSMQ 作为中间层,因为现在几乎每个版本的 Windows 都附带它,并且或多或少是为此类事情量身定制的。因此,浏览各层,在这里,您有:
这里有从 SQL Server 访问 MSMQ 的示例代码: http://www.codeproject.com /KB/database/SqlMSMQ.aspx
Extended stored procedures are what I thought of first, too, and are probably the solution I'd use if I wanted to run the monitoring app on the SQL Server itself. But I'm guessing that's probably not the case.
I'd suggest using MSMQ as an intermediate layer, myself, since it comes with just about every version of Windows these days and is more or less tailor-made for this sort of thing. So, going through the layers, here, you have:
There's sample code for accessing MSMQ from SQL Server here: http://www.codeproject.com/KB/database/SqlMSMQ.aspx
您可以触发扩展存储过程 ,这会通知您的托盘。
也许这个链接更好。
You could trigger extended stored procedure, which would notify your tray.
Maybe this link is better.