如何在SQL SERVER 2008中使用触发器

编程入门 行业动态 更新时间:2024-10-27 10:30:38
本文介绍了如何在SQL SERVER 2008中使用触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在触发器中有一个查询plz尽快给我回复 以下是我的表格和插入代码 ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,, thera是2张桌子 1件商品 2件商品 产品领域 -项目名称 -Size -Purchase -Available -Balance item字段 Item_Name 尺寸 库存 ________________ 一旦我们在产品领域输入记录,库存将自动在项目表中增加 例如 产品表项目TABLE -Item名称包袋 -Size 3 3 -Purchase 10 -Available 10 -Balance 20库存20 一旦我们在包中插入第二条记录,产品表余额现在是20 + 10 = 30,那么30将会在现货的领带表中提升= 30 我的插入代码如下 -------------------------- -------------------------------------------------- --------------------------------

I have one query in trigger plz give me reply as soon as possible below is my table and insert code ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, thera are 2 tables 1-product 2-item product fields -Item Name -Size -Purchase -Available -Balance item Fields Item_Name Size Stock ________________ As soon as we enter record in product fields stock will increase automatically in item table For Example Product Table Item TAble -Item Name Bag Bag -Size 3 3 -Purchase 10 -Available 10 -Balance 20 Stock 20 As soon as we insert second record in bag and product table balance is now 20+10=30 than that 30 will be upadted in tiem table in stock =30 my insert code is as below ------------------------------------------------------------------------------------------------------------

SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\New_Project\App_Data\Database.mdf;Integrated Security=True;User Instance=True"); con.Open(); SqlCommand cmd = new SqlCommand("insert into product values('" + TextBox1.Text + "','" + TextBox2.Text + "'," + TextBox3.Text + ",'" + TextBox4.Text + "','" + TextBox5.Text + "')", con); cmd.ExecuteNonQuery(); ClientScript.RegisterStartupScript(Page.GetType(), "Submit", "<script language='javascript'>alert('Data is Saved.....!!!')</script>"); TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; con.Close(); GridView1.DataBind();

推荐答案

访问这里.. Triggers - Sql Server [ ^ ] visit here.. Triggers -- Sql Server[^]

更多推荐

如何在SQL SERVER 2008中使用触发器

本文发布于:2023-10-23 18:44:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521697.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:触发器   如何在   SERVER   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!