问题描述
当我插入一笔数据成功后;自动执行更新另外一个表格的动作;如下代码;更新不起作用stringsql="insertintodraw(ID,Line,DateTime,DUser,Quantity,category,remark,action)values(@ID,@Line,CONVERT(varchar(100),GETDATE()),@DUser,@Quantity,@category,@remark,@action)";try{SqlCommandcmd=newSqlCommand(sql,DBHelper.con);DBHelper.con.Open();cmd.Parameters.AddWithValue("@ID",this.txtid.Text.Trim());cmd.Parameters.AddWithValue("@line",this.txtLine.Text.Trim());cmd.Parameters.AddWithValue("@DUser",this.txtUser.Text.Trim());cmd.Parameters.AddWithValue("@Quantity",this.txtqty.Text.Trim());cmd.Parameters.AddWithValue("@category",this.cbocategory.Text.Trim());cmd.Parameters.AddWithValue("@remark",this.txtremark.Text);cmd.Parameters.AddWithValue("@action",this.rdodraw.Text.Trim());cmd.CommandText=sql;intresult=cmd.ExecuteNonQuery();if(result==1){stringsql1="Updatedatesetstatus='在线'whereid=@ID";cmd.Parameters.AddWithValue("@ID",this.txtid.Text.Trim());DBHelper.con.Open();SqlCommandcmd1=newSqlCommand(sql1,DBHelper.con);intresult1=cmd.ExecuteNonQuery();if(result1==1){MessageBox.Show("添加成功","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);}}else{MessageBox.Show("添加失败","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);}
解决方案
解决方案二:
触发器问题说的不明