SQL 访问 INSERT INTO 失败 [英] SQL Access INSERT INTO fails
问题描述
我正在尝试制作一个使用 OLEDB 连接到 Microsoft Access 数据库的 Visual Basic 应用程序.在我的数据库中,我有一个具有以下布局的用户表
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')
但是我似乎收到了这个语句的错误,根据 VB,这是一个语法错误.
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...
所以问题是我只能插入一个字段,但不能全部插入 3 个(不包括 ID 字段,因为它是自动编号).
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
推荐答案
密码是保留字 并且必须用括号括起来 [密码]
Password is a reserved word and must be bracketed [password]
INSERT INTO Users (Username, [Password], Email)
VALUES ('004606', 'Password', 'Email@Mail.com')
这篇关于SQL 访问 INSERT INTO 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!