为什么我无法使用SqlCommand创建触发器? [英] Why am I unable to create a trigger using my SqlCommand?

查看:95
本文介绍了为什么我无法使用SqlCommand创建触发器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该行 cmd.ExecuteNonQuery();

cmd.CommandText

cmd.CommandText

CREATE TRIGGER  subscription_trig_0  ON  subscription   AFTER INSERT  AS  UPDATE user_data SET msg_count=msg_count+1 FROM user_data
JOIN INSERTED ON user_data.id = INSERTED.recipient; 

例外:

Incorrect syntax near the keyword 'TRIGGER'.

然后使用VS 2010,连接到相同的文件(mdf文件),我在上面运行了查询我收到一条成功消息。

Then using VS 2010, connected to the very same file (a mdf file) I run the query above and I get a success message. WTF!

推荐答案

您是否将 CommandType 设置错误?

这篇关于为什么我无法使用SqlCommand创建触发器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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