Синтаксическая ошибка в инструкции UPDATE
привет, у меня есть "(синтаксическая ошибка в инструкции UPDATE.)", когда я обновляю запись в базе данных access с помощью VB.net код.Спасибо за помощь.
Что я уже пробовал:
Private Sub btnEdit_Click(sender As Object, e As EventArgs) Handles btnEdit.Click myconnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Horng Woei\Documents\Klinik OCEANA.mdb" myconnection.Open() Dim cmd As New OleDbCommand Dim ds As New DataSet da = New OleDbDataAdapter("select * from [PatientData]", myconnection) If da.Fill(ds) Then Dim query As String = "update [PatientData] set [PatientName],[Age],[Gender],[Nationality],[ContactNo],[DOR],[IC],[Blood Type],[Weight(kg)],[Height(cm)],[Allergies] = '" + txtName.Text + "','" + txtAge.Text + "','" + cboGender.Text + "','" + cboNationality.Text + "','" + txtContact.Text + "','" + txtDOR.Text + "','" + txtIC.Text + "','" + cboBloodType.Text + "','" + txtWeight.Text + "','" + txtHeight.Text + "','" + txtAllergies.Text + "' where [PatientID] = '" + txtID.Text + "'" cmd.Parameters.AddWithValue("@PatientName", txtName.Text) cmd.Parameters.AddWithValue("@Age", txtAge.Text) cmd.Parameters.AddWithValue("@Gender", cboGender.Text) cmd.Parameters.AddWithValue("@Nationality", cboNationality.Text) cmd.Parameters.AddWithValue("@ContactNo", txtContact.Text) cmd.Parameters.AddWithValue("@DOR", txtDOR.Text) cmd.Parameters.AddWithValue("@IC", txtIC.Text) cmd.Parameters.AddWithValue("@Blood Type", cboBloodType.Text) cmd.Parameters.AddWithValue("@Weight(kg)", txtWeight.Text) cmd.Parameters.AddWithValue("@Height(cm)", txtHeight.Text) cmd.Parameters.AddWithValue("@Allergies", txtAllergies.Text) cmd = New OleDbCommand(query, myconnection) cmd.ExecuteNonQuery() cmd.Dispose() MsgBox("Data Updated Successfully!") myconnection.Close() filterrecords("") End If End Sub