C#/ SQL监听器告诉我,如果某行被插入到表 [英] C# / SQL Listener to tell me if a row has been inserted into a table

查看:562
本文介绍了C#/ SQL监听器告诉我,如果某行被插入到表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以张贴的示例代码或者告诉我如何建立一个监听器,通知我,如果一个新行插入到一个SQL Server数据库(触发事件)?

Can someone post sample code or tell me how to set up a listener to notify me (trigger an event) if a new row is inserted into a SQL Server database?

我不希望使用任何SQL Server的消息或经纪人的服务。我现在有一个文件,侦听器时新行被附加到一个平面文件,这将通知我。我想对数据库表做同样的。

I don't want to use any of the SQL Server messaging or broker services. I currently have a file listener which will notify me when new rows are appended to a flat file. I would like to do the same for a database table.

推荐答案

您也许寻找的的SqlDependency 类,可以让你的代码寄存器发生更改时得到通知?

Are you perhaps looking for the SqlDependency class, that lets your code register to be notified when changes occur?

的SqlDependency 是理想的缓存方案,你的ASP.NET应用程序或中间层服务需要保持在内存中缓存的某些信息。 的SqlDependency 让你收到通知时更改数据库的原始数据,以便高速缓存可以被刷新。

SqlDependency is ideal for caching scenarios, where your ASP.NET application or middle-tier service needs to keep certain information cached in memory. SqlDependency allows you to receive notifications when the original data in the database changes so that the cache can be refreshed.

还是今年秋季的东西,你不允许的领域内,它不是完全清楚?

Or does this fall within the realm of things that you're disallowing, it's not entirely clear?

这篇关于C#/ SQL监听器告诉我,如果某行被插入到表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆