當前位置:編程學習大全網 - 網站源碼 - VS asp.net 點擊“提交訂單”按鈕,使庫存減1。sql語句如下:

VS asp.net 點擊“提交訂單”按鈕,使庫存減1。sql語句如下:

string kucun = "update products set [庫存]=[庫存]-"+qty1+" where [商品名字]=" + pname + "";

妳這句話裏,存在了壹個很嚴重的錯誤。

update 是更新數據的意思,也就是說,更新對應條件下某個鍵值的值。他是沒有返回值的。

而且妳不能讓SQL去計算這個更新的值,而是通過程序來實現。

解決方案:

string oldkucun = "select [庫存] form products where [商品名字]=" + pname + "";

string newkucun = (Int32.pasue(oldkucun) - 1).ToString();

string kucun = "update products set [庫存]=“ + newkucun +" where [商品名字]=" + pname + "";

  • 上一篇:請高手 編寫 通達信 選股公式,
  • 下一篇:如何用js刪除表格壹行或者多行
  • copyright 2024編程學習大全網