0
Protected Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click

a = "insert into sales values('" + TextBox15.Text + "','" + TextBox22.Text + "','" + TextBox16.Text + "','" + TextBox17.Text + "','" + TextBox18.Text + "','" + TextBox19.Text + "','" + TextBox20.Text + "','" + TextBox21.Text + "','" + Label13.Text + "','" + Label18.Text + "')"

cmd = New SqlCommand(a, con)    
con.Open()
cmd.ExecuteNonQuery()
cmd.Dispose()
con.Close()
MsgBox("insert successfully")
Dim s As Integer
s = TextBox20.Text
a = "update product set quantityavailable=quantityavailable - '" + s + "' where productid='" + TextBox15.Text + "'"
cmd = New SqlCommand(a, con)
con.Open()
cmd.ExecuteNonQuery()
cmd.Dispose()
con.Close()
MsgBox("update successfully")
End Sub
4

1 回答 1

0

试试看嘛

update product set quantityavailable=quantityavailable - "+ s.ToString() +" where productid='" + TextBox15.Text + "'"

并尝试阅读有关 SqlParemeters 的信息。

于 2013-10-23T06:02:22.100 回答