下面的查询用于将数据插入数据库
msql = "update tb_temp set qty = qty + '" & Trim(txtStock.Text) & "' where product_id='" & Trim(cbProductID.Text) & "' "
它工作正常并运行添加功能,就像它应该
但是当我将算术运算符更改为 - 减法
时msql = "update tb_temp set qty = qty - '" & Trim(txtStock.Text) & "' where product_id='" & Trim(cbProductID.Text) & "' "
它会像这样返回非空的异常
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
有人可以解释一下吗?
之前谢谢答案 0 :(得分:0)
我自己解决了..事实证明我用过多单引号:)
在
msql = "update tb_temp set qty = qty - '" & Trim(txtStock.Text) & "' where product_id='" & Trim(cbProductID.Text) & "' "
在
msql = "update tb_temp set qty = qty - " & Trim(txtStock.Text) & " where product_id='" & Trim(cbProductID.Text) & "' "
我删除" &
之前的单引号并且它有效!