Click here to Skip to main content
15,942,710 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Item     qty
1        100kg
2        200kg

item      qty
1        20kg
2        30kg

*Subtract the qty from stock table insert to sale table

What I have tried:

Strcmd = " UPDATE stock SET qty = stock.qty - sales.qty FROM stock INNER JOIN sales ON stock.item = sales.item"
            'Strcmd = " insert into sales (item,qty)values (@item,@qty)"
            conn = New SqlConnection(Strconn)
            cmd = New SqlCommand(Strcmd, conn)
            cmd.Parameters.Add("@item", SqlDbType.VarChar).Value = TextBox1.Text
            cmd.Parameters.Add("@qty", SqlDbType.Int).Value = TextBox2.Text
            dr = cmd.ExecuteReader()
Updated 22-Jan-18 0:54am
Member 13067646 22-Jan-18 6:37am    
Please Help me
[no name] 22-Jan-18 6:46am    
Where is your Item column Comes?Please repost your question with all the details.
Member 13067646 22-Jan-18 6:48am    
Item(id) i Change
please help me
[no name] 22-Jan-18 7:11am    
If you want to insert then why are you writting Update statements.Please update your question.
ZurdoDev 22-Jan-18 9:00am    
What is your question?

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