这是我的代码。
我正在尝试更新按钮上的记录
Dim conn2 As SqlConnection
Dim cmd2 As New SqlCommand
conn2 = New SqlConnection("Persist Security Info=false;User Id=justin;Data Source=ARULJUSTIN\SQLEXPRESS;Initial Catalog=firemaintain;Integrated Security=True;Pooling=False")
conn2.Open()
cmd2.Connection = conn2
'conn = "update hyrdranmaintain SET uhlcondition, uhdhcondition,uhrhcondition values @lcondition, @hcondition, @rhcondition Where Recordno = '" & txtcase.ToString & "'",conn
cmd2.CommandText = "UPDATE hydrantmaintain SET uhlcondition, uhdhcondition, uhrhcondition values @lcondition, @hcondition, @rhcondition Where Recordno= @rcordno"
cmd2.Parameters.AddWithValue("@lcondition", cmblv.SelectedItem)
cmd2.Parameters.AddWithValue("@hcondition", cmbdh.SelectedItem)
cmd2.Parameters.AddWithValue("@rhcondition", cmbrh.SelectedItem)
cmd2.Parameters.AddWithValue("@rcordno", Trim(txtcase.ToString))
cmd2.ExecuteNonQuery()
我收到了错误
System.Data.SqlClient.SqlException was unhandled Message=Incorrect syntax near ','
答案 0 :(得分:0)
这不是更新的正确语法。它应该是这样的:
UPDATE hydrantmaintain
SET uhlcondition = @lcondition
,uhdhcondition = @hcondition
,uhrhcondition = @rhcondition
WHERE Recordno= @rcordno