none
System.Data.OleDb.OleDbException: 'Syntax error in INSERT INTO statement.' what does this mean? RRS feed

  • Question

  • Imports System.Data.OleDb
    Module Module1
        Private cn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source = |DataDirectory|\New Microsoft Access Database.accdb")
        Public Sub Connect()
            If cn.State = ConnectionState.Closed Then cn.Open()
        End Sub

        Public Function InsertUpdateDelete(ByVal sql As String) As Boolean
            Connect()
            Dim cmd As New OleDbCommand(sql, cn)
            Return cmd.ExecuteNonQuery() > 0 'this was having problem
        End Function
    End Module
    Wednesday, November 6, 2019 4:22 PM

All replies

  • Hi,

    I'm afraid you need to provide code which calls function "InsertUpdateDelete" and value of a parameter "sql".

    Regards,

    Ashidacchi -- http://hokusosha.com

    Wednesday, November 6, 2019 11:01 PM
  • Hi Passyyyy,

    This error indicates that there is a problem with your insert statement. Such as a string error, or whether missing a keyword, etc. 
    In order to solve the issue more efficiently, can you provide the sql statement which in the function InsertUpdateDelete ?

    Best Regards
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 7, 2019 1:48 AM