还是触发器的问题

angleoldhen angleoldhen 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
asp.net2.0:

protected void Button1_Click(object sender, EventArgs e)
{
string connstring = ConfigurationManager.ConnectionStrings["qztvoaConnectionString"].ToString();
SqlConnection dbConnection = new SqlConnection(connstring);
dbConnection.Open();
string query = "insert into ttapeborrow(tapecode,borrowman,borrowdate,borrowreason,operateman,operatedate) values(@tapecode,@borrowman,@borrowdate,@borrowreason,@operateman,@operatedate)";
SqlCommand dbCommand = new SqlCommand(query, dbConnection);
dbCommand.Parameters.Add(new SqlParameter("@tapecode", tapecodeBox.Text.ToString()));
dbCommand.Parameters.Add(new SqlParameter("@borrowman", userDropDownList.SelectedItem.Text.ToString()));
dbCommand.Parameters.Add(new SqlParameter("@operateman", Session["username"].ToString()));
dbCommand.Parameters.Add(new SqlParameter("@borrowreason", reasonDropDownList.SelectedItem.Text.ToString()));
dbCommand.Parameters.Add("@operatedate", SqlDbType.DateTime).Value = DateTime.Now.Date;
dbCommand.Parameters.Add("@borrowdate", SqlDbType.DateTime).Value = DateTime.Now.Date;
try
{
dbCommand.ExecuteNonQuery();
Response.Write("<script>");
Response.Write("window.alert('添加成功')");
Response.Write("</script>");
}
catch
{
Response.Write("<script>");
Response.Write("window.alert('添加失败,请与数据库管理员联系')");
Response.Write("</script>");
}
dbConnection.Close();
}

触发器:
CREATE TRIGGER Trigger1
ON dbo.ttapeborrow
After insert
AS
begin
update ttape
set instack = '0'
from ttape a, ttapeborrow b
where a.tapecode = b.tapecode
end

现在的情况是:只要有这个触发器,上面那段代码就无法添加记录,而一旦把触发器去掉,添加记录就正常,触发器语法是没错了,然到是逻辑错了?
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
angleoldhen
MS-SQL Server 34,876 成员 254,635 内容