真爛的Access及Access關鍵字

之前作數據庫開發一直使用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
 
2008年1月11日更新說明:在此把回帖用戶補充的關鍵字都補上了。
最後說明一下:在Access中和在MS SQL中同樣,對關鍵字的轉義是使用「[」和「]」的,好比你的數據庫中某個表中有以上述關鍵字做爲字段名的,記得在該字段先後分別加上「[」和「]」,如[user],[password],[yes],不過建議仍是儘可能避免使用關鍵字。
另外有情提示:若是碰見報「insert into"語句錯誤的狀況,多半就是由於你使用關鍵字了。記得轉義或者更改字段名。
相關文章
相關標籤/搜索