c# - update stock quantity keeping along the previous quantity -


i having problem updating database stock. want add stock previous stock available in inventory error check mysql syntax before where. , query.

"update tblproducts set quantity=quantity+'"+txtaddqty.text+"' productid='"+txtproductid.text+"' " 

where wrong.

you concatenating quantity , string (txtaddqty.text)

"update tblproducts set quantity = quantity + " + convert.toint32(txtaddqty.text) +  " productid='" + txtproductid.text + "'" 

caution

  1. above sql statement fails if txtaddqty.text gives alphabets instead of numeric value.
  2. also fail if txtproductid.text gives unexpected value
  3. not recommended way of doing things database application.

instead of making sql statement string concatenation should use parametrized sql query. doing prevent of sql injection problem.


Comments

Popular posts from this blog

javascript - Replicate keyboard event with html button -

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Web audio api 5.1 surround example not working in firefox -