欢迎光临
我们一直在努力

创建CLR自定义触发器-C#-.NET教程,C#语言

建站超值云服务器,限时71元/月

第一步:在visual studio 2005中编写代码

using system;

using system.data;

using system.data.sql;

using system.data.sqlserver;

using system.data.sqltypes;

public partial class triggers

{

// enter existing table or view for the target and uncomment the attribute line

// [sqltrigger (name="mytrigger", target="table1", event="for update")]

public static void mytrigger()

{

sqltriggercontext mytriggercontext = sqlcontext.gettriggercontext();

sqlpipe mypipe = sqlcontext.getpipe();

sqlcommand mycommand = sqlcontext.getcommand();

if (mytriggercontext.triggeraction == triggeraction.insert)

{

mycommand.commandtext = "select * from sptesttbl";

}

mypipe.execute(mycommand);

}

}

第二步:编译,部署(build,deploy)

第三步:注册到yukon

语法:

create trigger trigger_name on table_name for insert|update|delete

as external name assembly_name.class_name.clr_trigger_name

示例:

create trigger mytrigger on testtbl1 for insert

as external name udt.triggers.mytrigger

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 创建CLR自定义触发器-C#-.NET教程,C#语言
分享到: 更多 (0)

相关推荐

  • 暂无文章