此查询在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
答案 0 :(得分:2)
Langauge
是保留关键字。通过包裹[ ]
来逃避它。
sql1 = "INSERT INTO CustomerDtl (..., [Language], ....) VALUES(...)"