简体   繁体   English

如何捕获已在sql server上触发的触发器

[英]How to catch that a trigger has been fired on sql server

I have a table on SQL and when there is an insert to this table I want to print this inserted data. 我有一个关于SQL的表,当有一个插入到这个表时,我想打印这个插入的数据。

What I am thinking in: 我在想什么:

  1. Create a trigger on that table. 在该表上创建一个触发器。
  2. Handle the printing event on c# after the trigger works. 触发器工作后,在c#上处理打印事件。

My problem 我的问题

I don't know what is the name of the feature that makes ac# code fires when a trigger fires. 我不知道触发器触发时ac#代码触发的功能名称是什么。

Can you help me with this issue, please? 你能帮帮我解决这个问题吗?

There are several ways of solving this problem, and the soluton depends on the system architecture (permissions, accesibility), and the knowledge to implement it. 有几种方法可以解决这个问题,而解决方案取决于系统架构(权限,可访问性)以及实现它的知识。

There are basically this options, which are affected by the pointed out factors: 基本上有这个选项,受到指出的因素的影响:

  • printing directly from the inserting application or notifying from the inserting application: can you change that application? 直接从插入应用程序打印或从插入应用程序通知:您可以更改该应用程序吗? is it possible to comunicate from tha application to the printing application. 是否有可能从应用程序到打印应用程序进行通信。 (It could be implemented, for example, with WCF) (例如,可以使用WCF实现)
  • sql dependencies (SQL Notification request) : the printing application should create and subscribe to a sql dependency: do you have permission to create the dependencies in the server? sql依赖项(SQL Notification request) :打印应用程序应该创建并订阅sql依赖项:你是否有权在服务器中创建依赖项?
  • polling: is the quick & dirty solution: use a "timer" to check if there is new data and print it when available 轮询:快速而肮脏的解决方案:使用“计时器”检查是否有新数据并在可用时打印

The last solution is the one that will pose the least problems. 最后一个解决方案是问题最少的解决方案。 It's not "smart" but it's very easy to implement. 这不是“聪明”,但它很容易实现。 You can adjust the polling period depending on the expected number of messages and the "real-time" requirements of the pringing application. 您可以根据预期的消息数量和pringing应用程序的“实时”要求调整轮询周期。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在Entity Framework中尝试/捕获sql server trigger错误 - Can I try/catch sql server trigger error in Entity Framework 如何捕获在ContinueContin部分中引发的异常? - How to catch an Exception that has been thrown in the ContinueWith part of a task? 检查事件是否至少被触发过一次 - Check if an event has been fired at least once 是否可以在C#应用程序中捕获SQL Server触发器或为Server Data创建自己的触发器 - Is it possible to catch SQL Server trigger or create own trigger for Server Data in C# Application 如何检查ddl.selectedindexchange事件是否已在页面加载上触发 - how to check if the ddl.selectedindexchange event has been fired on the page load 仅在触发事件后,C#方法如何返回? - How can a C# Method return only after Event has been fired? Excel VSTO如何检查在激发WorkbookBeforeClose事件后是否从对话框中触发了取消按钮? - Excel VSTO how to check if the Cancel button has been triggered from the dialog after the WorkbookBeforeClose event is fired? SQL Server 2008:确保已将IncludeMetadataConvention添加到DbModelBuilder约定中 - SQL Server 2008: Ensure that IncludeMetadataConvention has been added to the DbModelBuilder conventions ExecuteScalar:连接属性尚未初始化。 SQL Server连接 - ExecuteScalar: Connection property has not been initialized. SQL Server Connection SQL Server错误:ExecuteNonQuery:连接属性尚未初始化 - SQL Server error: ExecuteNonQuery: Connection property has not been initialized
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM