Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
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
------------------------------------------------------------------------------------------------------------
C#
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();
Posted
v2
Comments
Thanks7872 11-Nov-13 0:04am    
And? Where is the question?

1 solution

visit here..
Triggers -- Sql Server[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900