减法mysql vb net

时间:2014-04-05 21:11:27

标签: mysql vb.net

下面的查询用于将数据插入数据库

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

有人可以解释一下吗?

之前谢谢

1 个答案:

答案 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) & "' "

我删除" &之前的单引号并且它有效!