以前做数据库开发一直使用SQL Server和MySQL来开发,有比较好的工具,通常遇到关键字会以变色字体演示,一般到也不会出现什么问题,最近做一个小东东,想尝试一下Access,经常是在直接用SQL语句查询没有问题,一到程序里面就不行了,动不动就报“IErrorInfo.GetDescription 因 E_FAIL(0x80004005) 而失败。”这个错误,查了半天才知道是因为使用了Access的关键字,我吐,发誓以后再也不用Access了。
为了避免大家犯同样的错误,现将Access的关键字列出来,如果以后在编程中你遇到了同样的错误,请看看是否使用了Access的关键字。
-A
ADD
ALL
Alphanumeric
ALTER
AND
ANY
Application
AS
ASC
Assistant
AT
AUTOINCREMENT
Avg
-B
BETWEEN
BINARY
BIT
BOOLEAN
BY
BYTE
-C
CHAR, CHARACTER
COLUMN
CompactDatabase
CONSTRAINT
Container
Count
COUNTER
CREATE
CreateDatabase
CreateField
CreateGroup
CreateIndex
CreateObject
CreateProperty
CreateRelation
CreateTableDef
CreateUser
CreateWorkspace
CURRENCY
CurrentUser
-D
DATABASE
DATE
DATETIME
DELETE
DESC
Description
DISALLOW
DISTINCT
DISTINCTROW
Document
DOUBLE
DROP
-E
Echo
Else
End
Eqv
Error
EXISTS
Exit
-F
FALSE
Field, Fields
FillCache
FLOAT, FLOAT4, FLOAT8
FOREIGN
Form, Forms
FROM
Full
FUNCTION
-G
GENERAL
GetObject
GetOption
GotoPage
GROUP
GROUP BY
GUID
-H
HAVING
-I
Idle
IEEEDOUBLE, IEEESINGLE
If
IGNORE
Imp
IN
INDEX
Index, Indexes
INNER
INSERT
InsertText
INT, INTEGER, INTEGER1, INTEGER2, INTEGER4
INTO
IS
-J
JOIN
-K
KEY
-L
LastModified
LEFT
Level
Like
LOGICAL, LOGICAL1
LONG, LONGBINARY, LONGTEXT
-M
Macro
Match
Max, Min, Mod
MEMO
Module
MONEY
Move
-N
NAME
NewPassword
NO
Not
Note
NULL
NUMBER, NUMERIC
-O
Object
OLEOBJECT
OFF
ON
OpenRecordset
OPTION
OR
ORDER
Orientation
Outer
OWNERACCESS
-P
Parameter
PARAMETERS
Partial
Password
PERCENT
PIVOT
PRIMARY
PROCEDURE
Property
-Q
Queries
Query
Quit
-R
REAL
Recalc
Recordset
REFERENCES
Refresh
RefreshLink
RegisterDatabase
Relation
Repaint
RepairDatabase
Report
Reports
Requery
RIGHT
-S
SCREEN
SECTION
SELECT
SET
SetFocus
SetOption
SHORT
SINGLE
Size
SMALLINT
SOME
SQL
StDev, StDevP
STRING
Sum
-T
TABLE
TableDef, TableDefs
TableID
TEXT
TIME, TIMESTAMP
TOP
TRANSFORM
TRUE
Type
-U
UNION
UNIQUE
UPDATE
USER
-V
VALUE
VALUES
Var, VarP
VARBINARY, VARCHAR
-W
WHERE
WITH
Workspace
-X
Xor
-Y
Year
YES
YESNO
ADD
ALL
Alphanumeric
ALTER
AND
ANY
Application
AS
ASC
Assistant
AT
AUTOINCREMENT
Avg
-B
BETWEEN
BINARY
BIT
BOOLEAN
BY
BYTE
-C
CHAR, CHARACTER
COLUMN
CompactDatabase
CONSTRAINT
Container
Count
COUNTER
CREATE
CreateDatabase
CreateField
CreateGroup
CreateIndex
CreateObject
CreateProperty
CreateRelation
CreateTableDef
CreateUser
CreateWorkspace
CURRENCY
CurrentUser
-D
DATABASE
DATE
DATETIME
DELETE
DESC
Description
DISALLOW
DISTINCT
DISTINCTROW
Document
DOUBLE
DROP
-E
Echo
Else
End
Eqv
Error
EXISTS
Exit
-F
FALSE
Field, Fields
FillCache
FLOAT, FLOAT4, FLOAT8
FOREIGN
Form, Forms
FROM
Full
FUNCTION
-G
GENERAL
GetObject
GetOption
GotoPage
GROUP
GROUP BY
GUID
-H
HAVING
-I
Idle
IEEEDOUBLE, IEEESINGLE
If
IGNORE
Imp
IN
INDEX
Index, Indexes
INNER
INSERT
InsertText
INT, INTEGER, INTEGER1, INTEGER2, INTEGER4
INTO
IS
-J
JOIN
-K
KEY
-L
LastModified
LEFT
Level
Like
LOGICAL, LOGICAL1
LONG, LONGBINARY, LONGTEXT
-M
Macro
Match
Max, Min, Mod
MEMO
Module
MONEY
Move
-N
NAME
NewPassword
NO
Not
Note
NULL
NUMBER, NUMERIC
-O
Object
OLEOBJECT
OFF
ON
OpenRecordset
OPTION
OR
ORDER
Orientation
Outer
OWNERACCESS
-P
Parameter
PARAMETERS
Partial
Password
PERCENT
PIVOT
PRIMARY
PROCEDURE
Property
-Q
Queries
Query
Quit
-R
REAL
Recalc
Recordset
REFERENCES
Refresh
RefreshLink
RegisterDatabase
Relation
Repaint
RepairDatabase
Report
Reports
Requery
RIGHT
-S
SCREEN
SECTION
SELECT
SET
SetFocus
SetOption
SHORT
SINGLE
Size
SMALLINT
SOME
SQL
StDev, StDevP
STRING
Sum
-T
TABLE
TableDef, TableDefs
TableID
TEXT
TIME, TIMESTAMP
TOP
TRANSFORM
TRUE
Type
-U
UNION
UNIQUE
UPDATE
USER
-V
VALUE
VALUES
Var, VarP
VARBINARY, VARCHAR
-W
WHERE
WITH
Workspace
-X
Xor
-Y
Year
YES
YESNO
2008年1月11日更新说明:在此把回帖用户补充的关键字都补上了。
最后说明一下:在Access中和在MS SQL中一样,对关键字的转义是使用“[”和“]”的,比如你的数据库中某个表中有以上述关键字作为字段名的,记得在该字段前后分别加上“[”和“]”,如[user],[password],[yes],不过建议还是尽量避免使用关键字。
另外有情提示:如果遇见报“insert into"语句错误的情况,多半就是因为你使用关键字了。记得转义或者更改字段名。
本文转自周金桥51CTO博客,原文链接:
http://blog.51cto.com/zhoufoxcn/166428
,如需转载请自行联系原作者