在用户界面中获取触发值 [英] getting trigger value in the user interface

查看:53
本文介绍了在用户界面中获取触发值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个触发器,可以打印特定的行

i have a trigger and that print a particular line

create trigger triginsert on dbo.sample
after insert
as
begin
print 'added successfully'
end




如何在服务器端脚本中获得此打印语句




how can i get this print statement in my serverside script

推荐答案

在ADO.Net中,连接对象上有一个名为InfoMessage
的事件
您不会像写的那样获得每条消息,我认为它可以使用流来工作,该流会在有大量消息的地方或在有少量消息的末尾周期性地推出文本.

我尚未测试过当您的原始ADO命令导致执行触发器时该方法是否有效,但是,如果您可以答复并让我们所有人知道,那将是很好的.

In ADO.Net on the connection object there''s an event called InfoMessage

You don''t get each message as it''s written, I think it works using streams which pushes out the text periodically where there''s a lot of message or at the end where there''s few.

I haven''t tested that this works when your original ADO command is causing the trigger execution, but nonetheless, it would be good if you could reply and let us all know.

connection.InfoMessage += delegate(object sender, SqlInfoMessageEventArgs e)
{
  txtMessages.Text +="\n" + e.Message;
};



运行ADO.Net的SQL时,写入文本输出的所有消息都包括使用SQL中的PRINT命令写入的所有消息.

以下文章更详细地介绍了这一点:

http://www.dotnetcurry.com/ShowArticle.aspx?ID=344 [ ^ ]



Any messages written to the text output when running SQL for ADO.Net this includes all messages written using the PRINT command in SQL.

The following article covers this in more detail:

http://www.dotnetcurry.com/ShowArticle.aspx?ID=344[^]


这篇关于在用户界面中获取触发值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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