Синтаксическая ошибка в инструкции INSERT INTO. - PullRequest
0 голосов
/ 16 мая 2018

Private Sub Button1_Click (отправитель ByVal как System.Object, ByVal e как System.EventArgs) Обрабатывает Button1.Click cs = "Provider = Microsoft.ACE.OLEDB.12.0; Источник данных = | DataDirectory | \ coder.accdb" con = New OleDbConnection (cs) con.Open () cmd = New OleDbCommand ("ВСТАВЬТЕ ИНФОРМАЦИЮ О СТУДЕНТЕ ('" + txtid.Text + "', '" + txtroll.Text + "', '" + txtfname.Text + "', '" + txtlname.Text + "' , '' + txtpclass.Text + "','" + txtpname.Text + "','" + txtmname.Text + "','" + txtfoccupation.Text + "','" + txtmoccupation.Text + "' , '"+ txtaddress.Text +"', '"+ txtcontact.Text +"', '"+ txtlandl.Text +"', '"+ txtpschool.Text +"') ", con)

   Dim i As Integer = cmd.ExecuteNonQuery

    If (i >= 0) Then
        MessageBox.Show("Data saved Successfully", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information)

    Else
        MessageBox.Show("Data not  saved Successfully", "Unsuccessfull!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)


    End If
    con.Close()

End Sub

1 Ответ

0 голосов
/ 16 мая 2018

В операторе вставки отсутствует ключевое слово VALUES.См .: https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2007/bb208861(v=office.12)

insert into myTable values (val1, val2, val3, ...)

Или:

insert into myTable (col1, col2, col3, ...) values (col1, col2, col3, ...)
...