使用Visual Studio 2017访问2013代码.Net System.Data.OleDB.OleDbException(0x80040e14):插入语句中的语法错误

时间:2018-08-03 21:53:22

标签: .net visual-studio ms-access-2013

感谢您的帮助,以便了解如何在使用Visual Studio 2017 Access 2013和.Net的情况下解决此问题。show show error

System.Data.OleDB.OleDbException (0x80040e14): Syntax error in Insert Into Statement.

这是代码:

Imports System.Data
Imports System.Data.OleDb

Public Class NewRecord
    Dim conn As New OleDbConnection
    Dim comando As New OleDbCommand
    Dim cdmText As String
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Try
            conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\fcp40_000\source\repos\connectbasedatos\connectbasedatos\bin\Debug\codigo.accdb;Persist Security Info=False"
            conn.Open()
            cdmText = "INSERT INTO Persona([IDPersona],[Nombres],[Apellido];[Correo],[Direccion],[FechaReg]) Values (TextID,TextNombre,TextApellido,TextEmail,TextDireccion,DateTimePicker1)"
            comando = New OleDbCommand(cdmText, conn)
            comando.Parameters.AddWithValue("@IDPersona", TextID.Text)
            comando.Parameters.AddWithValue("@Nombres", TextNombre.Text)
            comando.Parameters.AddWithValue("@Apellido", TextApellido.Text)
            comando.Parameters.AddWithValue("@Correo", TextEmail.Text)
            comando.Parameters.AddWithValue("@Direccion", TextDireccion.Text)
            comando.Parameters.AddWithValue("@FechaReg", DateTimePicker1)
            comando.ExecuteNonQuery()
            MsgBox("Registro guardado correctamente", vbInformation, "Aviso")
        Catch ex As Exception
            MsgBox(ex.ToString)
            MsgBox("Registro NO se guardado correctamente", vbCritical, "Atencion")

        End Try
        conn.Close()
    End Sub
End Class

系统显示的错误是: enter image description here

我尝试了不同的解决方案,但没有一个可行,谢谢您的帮助和支持。

0 个答案:

没有答案