Why is this a syntax error?
-
When I run this code I get this error message "Syntax error in INSERT INTO statement". Can anyone explain why my command is a syntax error? Thanks.
rsGuest.Open("Guest", ADOConnection, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Dim command As String command = "INSERT INTO Guest(Guest ID) VALUES('1111')" ADOConnection.Execute(command, rsGuest)
-
When I run this code I get this error message "Syntax error in INSERT INTO statement". Can anyone explain why my command is a syntax error? Thanks.
rsGuest.Open("Guest", ADOConnection, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Dim command As String command = "INSERT INTO Guest(Guest ID) VALUES('1111')" ADOConnection.Execute(command, rsGuest)
There are two possible reasons I can see. Firstly, your syntax is wrong:
command = "INSERT INTO Guest(Guest ID) VALUES('1111')"
Should becommand = "INSERT INTO Guest**[**Guest ID**]** VALUES('1111')"
Also, is [Guest ID] an identity (autonumber) column?Bob Ashfield Consultants Ltd
-
When I run this code I get this error message "Syntax error in INSERT INTO statement". Can anyone explain why my command is a syntax error? Thanks.
rsGuest.Open("Guest", ADOConnection, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Dim command As String command = "INSERT INTO Guest(Guest ID) VALUES('1111')" ADOConnection.Execute(command, rsGuest)
-
column name Guest ID is having space so it cannot be used directly use it like this
command = "INSERT INTO Guest([Guest ID]) VALUES('1111')"
Regards KP