INSERT INTO语句中的语法错误。在Access中运行不在VB中

时间:2013-07-20 10:43:39

标签: asp.net .net sql vb.net ms-access-2007

此查询在Access 2007中运行完美但当我尝试在我的代码中执行它时,我在INSERT INTO语句中出现语法错误。有人请帮忙。

Dim sql1 As String
sql1 = "INSERT INTO CustomerDtl (KioskID, ClientID, Language, SalesType) VALUES ('AD903',1,'English','Wholesale')"
ObjAccess.ExecuteQuery(sql1)

这是ExecuteReader函数:

Public Function ExecuteQuery(ByVal SQLQuery As String)

        'This Function Executes SQL Statement against connection and returns number of rows affected'

        dbCommand = New OleDbCommand
        Call OpenConnection()

        With dbCommand
            .Connection = dbConnection
            .CommandType = CommandType.Text
            .CommandText = SQLQuery
            .ExecuteNonQuery()
            .Dispose()
        End With

        Call CloseConnection()

End Function

1 个答案:

答案 0 :(得分:2)

Langauge是保留关键字。通过包裹[ ]来逃避它。

sql1 = "INSERT INTO CustomerDtl (..., [Language], ....) VALUES(...)"