0
我寫的代碼更新到從文本框減少一定的價值這樣 Textbox4.Text with value = "5"
減少表PRO_BALANCE
場 Combobox2.Text with value = "30000"
在表訪問SQL更新查詢沒有更新表
Try
Dim constr As String = ConfigurationManager.ConnectionStrings("WindowsApplication1.My.MySettings.DatabaseMobileConnectionString").ConnectionString
'Dim con As New OleDbConnection(constr)
'Dim cmd As OleDbCommand
Dim cmdtext As String = "UPDATE PRODUCT" & _
" SET PRO_BALANCE = PRO_BALANCE -?" & _
" WHERE (PRO_ID = ?)"
Using con As New OleDbConnection(constr)
Using cmd As New OleDbCommand(cmdtext, con)
cmd.CommandType = CommandType.Text
cmd.Parameters.Add("@pro_Balance", OleDbType.SmallInt).Value = Val(TextBox4.Text)
cmd.Parameters.Add("@Pro_ID", OleDbType.SmallInt).Value = Val(ComboBox2.Text)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
End Using
Catch ex As Exception
End Try
匹配PRO_ID
字段這是什麼都沒有發生場PRO_BALANCE萬變不離其宗沒有減少
PRO_ID PRO_BALANCE
30000 50
這將是
PRO_ID PRO_BALANCE
30000 45
它可能與您的數據類型有關。 'OleDbType.SmallInt'映射到Int16,因此該Id處於溢出邊緣。同樣使用Val返回一個Double,所以你有一個數據轉換。此外,擺脫空嘗試/捕捉 - 你吞嚥任何代碼可能會報告的所有錯誤 – Plutonix