SQL Access INSERT INTO fails

泪湿孤枕 提交于 2019-12-20 02:52:28

问题


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@Mail.com')

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


回答1:


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

INSERT INTO Users (Username, [Password], Email)
VALUES ('004606', 'Password', 'Email@Mail.com')



回答2:


Reserved word is in [...]

INSERT INTO Users (Username, [Password], Email)
VALUES ('004606', 'Password', 'Email@Mail.com')


来源:https://stackoverflow.com/questions/13527647/sql-access-insert-into-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!