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
- above sql statement fails if txtaddqty.text gives alphabets instead of numeric value.
- also fail if txtproductid.text gives unexpected value
- 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
Post a Comment