以下查询用于将数据插入数据库
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
有人可以解释吗?之前感谢
最佳答案
自己修复了..结果我使用了太多的单引号:)
之前
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) & "' "
我删除了
" &
之前的单引号,它起作用了!