我不想对某些表进行轮询,而是向等待中的 c# 应用程序发出信号,表明表中有新行要处理,可能是通过触发器。数据库是否有某种方式向控制台应用程序发送信号,或者我是否一直在轮询表以查找新行?
最佳答案
看看Query Notifications (SQL Server 2005+)。
Microsoft SQL Server 2005 introduces query notifications, new functionality that allows an application to request a notification from SQL Server when the results of a query change. Query notifications allow programmers to design applications that query the database only when there is a change to information that the application has previously retrieved.
这里有一个示例,说明如何编写一个简单的表单应用程序来注册通知查询:http://msdn.microsoft.com/en-us/library/a52dhwx7(VS.80).aspx .
这确实需要 Service Broker to be enabled在数据库上。
您应该查看 MSDN SqlDependency documentation 的备注 部分中的注释确保它是您场景的正确选择
关于c# - 如何从 SQL Server 向 c# 控制台应用程序发出信号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5251738/