妳這句話裏,存在了壹個很嚴重的錯誤。
update 是更新數據的意思,也就是說,更新對應條件下某個鍵值的值。他是沒有返回值的。
而且妳不能讓SQL去計算這個更新的值,而是通過程序來實現。
解決方案:
string oldkucun = "select [庫存] form products where [商品名字]=" + pname + "";
string newkucun = (Int32.pasue(oldkucun) - 1).ToString();
string kucun = "update products set [庫存]=“ + newkucun +" where [商品名字]=" + pname + "";