0

I'm having the following Error Message on data insertion: Syntax Error in Insert into Statement

Can anyone suggest what I am doing wrong please?

Remark: Field [No] is Primary Key and Data Type is Auto-Increment.

    con.Open()
    Dim tblRoom_Add As String

    tblRoom_Add = "INSERT INTO tblRoom1(No ,Room ,Check_In ,Check_Out ,User ,Price) VALUES " & _
   "('1', '1A', '10-5-2014', '10-6-2014', 'NaNa', '45')"

    Dim InsertInvoice = New OleDbCommand
    InsertInvoice = New OleDbCommand(tblRoom_Add, con)
    InsertInvoice.ExecuteNonQuery() 
3
  • 1
    Which DBMS is this? user is a keyword in SQL Server, so you would need to escape it like [user]. Commented Aug 13, 2014 at 8:22
  • its ACCESS and he is right Commented Aug 13, 2014 at 8:22
  • Its Ms Access Database Commented Aug 13, 2014 at 8:29

2 Answers 2

1

If this is MS Access NO and USER are reserved words. You either could use a differnt column name or wrap them in brackets[]

INSERT INTO tblRoom1([No], ...., [User], ...

Access 2007 reserved words and symbols

Sign up to request clarification or add additional context in comments.

Comments

0

its not like mysql integers and numbers should not be surronded by ' try this :

 tblRoom_Add = "INSERT INTO tblRoom1(No ,Room ,Check_In ,Check_Out ,[User] ,Price) VALUES (1, '1A', '10-5-2014', '10-6-2014', 'NaNa', 45)"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.