Синтаксическая ошибка в операторе INSERT into
Привет, я новичок в кодировании, получил "синтаксическую ошибку в инструкции INSERT INTO" после того, как нажал кнопку.Пожалуйста, дайте мне несколько советов и спасибо за помощь !
Что я уже пробовал:
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click myconnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Horng Woei\Documents\Klinik OCEANA.mdb" Dim Reader As OleDbDataReader If (txtName.Text = "" AndAlso txtAge.Text = "" AndAlso cboGender.Text = "" AndAlso cboNationality.Text = "" AndAlso txtContact.Text = "" AndAlso txtDOR.Text = "" AndAlso txtIC.Text = "" AndAlso cboBloodType.Text = "" AndAlso txtWeight.Text = "" AndAlso txtHeight.Text = "" AndAlso txtAllergies.Text = "") And (cboBloodType.SelectedIndex = 0 AndAlso cboGender.SelectedIndex = 0 AndAlso cboStatus.SelectedIndex = 0 AndAlso cboNationality.SelectedIndex = 0) Then MsgBox("Please fill in the form completely.") Else Try myconnection.Open() Dim query As String query = "Insert into [PatientData] ([PatientName],[Age],[Gender],[Marital Status][Nationality],[ContactNo],[DOR],[IC Number],[Blood Type],[Weight(kg)],[Height(cm)],[Allergies]) Values ('" & txtName.Text & "','" & txtAge.Text & "','" & cboGender.Text & "','" & cboStatus.Text & "','" & cboNationality.Text & "','" & txtContact.Text & "','" & txtDOR.Text & "','" & txtIC.Text & "','" & cboBloodType.Text & "','" & txtWeight.Text & "','" & txtHeight.Text & "','" & txtAllergies.Text & "')" cmd = New OleDbCommand(query, myconnection) Reader = cmd.ExecuteReader MessageBox.Show("You have stored data successfully!") myconnection.Close() Catch ex As Exception MsgBox(ex.Message) Finally myconnection.Dispose() txtName.Clear() txtAge.Clear() cboGender.ResetText() cboStatus.ResetText() cboNationality.ResetText() txtContact.Clear() txtDOR.Clear() txtIC.Clear() cboBloodType.ResetText() txtWeight.Clear() txtHeight.Clear() txtAllergies.Clear() refreshdata("") End Try End If End Sub