2

I'm trying to make a visual basic application which is connected to a Microsoft Access Database using OLEDB. Inside my database I have a user table with the following layout

ID - Autonumber
Username - Text
Password - Text
Email - Text

To insert data into the table I use the following query

INSERT INTO Users (Username, Password, Email) 
VALUES ('004606', 'Password', '[email protected]')

However I seem to get an error with this statement and according to VB it's a syntax error.

But then I tried to use the following query

INSERT INTO Users (Username) Values ('004606')

This query seemed to work absolutely fine...

So the problem is I can insert into just one field but not all 3 (excluding the ID field because it's an autonumber).

Any help would be appreciated, Thanks

2
  • Could you provide the error you receive? The INSERT seems fine Commented Nov 23, 2012 at 10:58
  • @il_guru Visual basic just says 'Synatx error in INSET INTO statement but don't worry the issue has been resolved thanks to Remou. Commented Nov 23, 2012 at 11:03

2 Answers 2

5

Password is a reserved word and must be bracketed [password]

INSERT INTO Users (Username, [Password], Email)
VALUES ('004606', 'Password', '[email protected]')
Sign up to request clarification or add additional context in comments.

Comments

0

Reserved word is in [...]

INSERT INTO Users (Username, [Password], Email)
VALUES ('004606', 'Password', '[email protected]')

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.