MS Access – Syntax error in INSERT INTO statement.


If you receive this error while working within the Visual Studio environment and  you are trying to append a record into an MS Access database, there could be a number of reasons that you are getting this error.  The reason I was receiving this error and quite frankly a rather frustrating reason at that was because of one of my field names, password.

I should know better than to give database field names that are reserved words or potentially reserved words, but since I was creating this app anticipating newbie programmers would take it over, I wanted to be as descriptive and unambiguous as possible.

So anyway, the following insert statement in Visual Studio failed when I went to update my database.

INSERT INTO users (username, password, first_name, last_name) VALUES ('jd', 'turk', 'John', 'Dorian');

I received the error: Syntax error in INSERT INTO statement.

What needed to be done here is enclose the field name “password” in brackets [].  So the statement should read:

INSERT INTO users (username, [password], first_name, last_name) VALUES ('jd', 'turk', 'John', 'Dorian');

Although the first query will work if you execute it within the MS Access environment, it will not work if you execute it within the code in your Visual Studio program.

Questions, comments and contributions are welcomed.

12 Comments

Filed under Sharing Stuff

12 responses to “MS Access – Syntax error in INSERT INTO statement.

  1. Bikram

    Thanks…It did solved my issue. I was using TimeStamp as my column name. Changing it solved my error.

  2. aloka

    You are my lucky star…
    I have been worked out for 24hours to find out the problems…
    Just because BRACKET!!!!

  3. Ay.

    Hello, thanks so much, I was using “Option” as my Table name, So, I enclose it in Square Backet, it works. Thank you.

    • Vanessa

      Thank you. Thank you. Thank you. I have spent the total of 18 hours trying to figure out what was wrong. It was not until I read your comment that I realized I had to check my table name for reserved words, too! My table was called USER.

  4. MDinVA

    GROUP is also a reserved word. Put in brackets and it worked like a charm!

  5. Vika Sylvana

    Thank you so much, i.m so headache to finf out the problems.
    so JUST BECAUSE BRACKET, DAMN!!

  6. Reco

    I don’t usually comment on forums. But this time, I just wanted to say THANK YOU. This helped me alot. I know im dumb but the [password] WORKS!

  7. asasoft

    so funny, even programme is a reserved word. Thank you guys you’re great

  8. Thank’s
    you are the best

  9. Dhvanit

    Thanks!! It was really a pain. Thank You for helping out.

  10. Tim

    You are a lifesaver!

Comment on this

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s