[C#]关于Access的“INSERTINTO语句的语法错误”问题
以下内容摘⾃⽹上资料,具体出处已不到,在此对原⽂作者表⽰感谢和敬意!
insert into 语句的语法错误经常会出现,主要原因是数据的字段名为access或sql数据库的保留字
解决的⽅法很简单,⼀是可以直接改掉那些字段名,⼆是在代码中将字段名⽤中括号"[ ]"括起来即可..
ACCESS中写SQL语句时尽量把表名和字段名⽤中括号括起来
ACCESS中写SQL语句时尽量把表名和字段名⽤中括号括起来,⼀般都要写成:
[TableName].FieldName,否则较长的中⽂名表名可能会被不识别。
当然,要是熟悉access或sql数据库的保留字,就不会有这样的烦恼.以下是SQL和ACCESS保留字,供⼤家参考:
在开发⽹店下载专家v3.0.0时,写⼊数据库的其中⼀个insert into 语句总是报错,可怜我花了⼀个多⼩时查错却⼀⽆所获,真衰啊。原来是因为表中的⼀个字段名设为了Moduel,丫的,原来是保留字
特此写下此⽂,严重警告⾃⼰不要在范这种低级错误了!!
SQL和ACCESS保留字
SQL保留字
action add aggregate all
alter after and as
asc avg avg_row_length auto_increment
between bigint bit binary
blob bool both by
cascade case char character
change check checksum column
columns comment constraint create
cross current_date current_time current_timestamp
data database databases date
datetime day day_hour day_minute
day_second dayofmonth dayofweek dayofyear
dec decimal default delayed
delay_key_write delete desc describe
distinct distinctrow double drop
end else escape escaped
enclosed enum explain exists
fields file first float
float4 float8 flush foreign
from for full function
global grant grants group
having heap high_priority hour
hour_minute hour_second hosts identified
ignore in index infile
inner insert insert_id int
integer interval int1 int2
int3 int4 int8 into
if is isam join
key keys kill last_insert_id
leading left length like
lines limit load local
lock logs long longblob
longtext low_priority max max_rows
match mediumblob mediumtext mediumint
middleint min_rows minute minute_second
middleint min_rows minute minute_second
modify month monthname myisam
natural numeric no not
null on optimize option
optionally or order outer
outfile pack_keys partial password
precision primary procedure process
processlist privileges read real
references reload regexp rename
replace restrict returns revoke
rlike row rows second
select set show shutdown
smallint soname sql_big_tables sql_big_selects
sql_low_priority_updates sql_log_off sql_log_update sql_select_limit
sql_small_result sql_big_result sql_warnings straight_join
starting status string table
tables temporary terminated text
then time timestamp tinyblob
tinytext tinyint trailing to
type use using unique
unlock unsigned update usage
values varchar variables varying
varbinary with write when
where year year_month zerofill
ACCESS保留字
Microsoft Access 版本:1.0 , 1.1 , 2.0
insert语句字段顺序Microsoft Access for Windows 95, version 7.0
Microsoft Access 97
本⽚⽂章中所列的单词和符号是保留字,应避免在Access字段名和变量名中使⽤,因为这些保留字在Access和Microsoft Jet database系统中有其特定的含义,如果你使⽤,将会出错。
-A
ADD
ALL (2.0, 7.0, 97)
Alphanumeric
ALTER
AND
ANY (2.0, 7.0, 97)
Application
AS
ASC
Assistant
AUTOINCREMENT
Avg
-B
BETWEEN
BINARY
BIT
BOOLEAN
BY
BYTE
-C
CHAR, CHARACTER
COLUMN
CompactDatabase (2.0, 7.0, 97) CONSTRAINT
Container (2.0, 7.0, 97)
Count
COUNTER (2.0, 7.0, 97) CREATE
CreateDatabase (2.0, 7.0, 97) CreateField (2.0, 7.0, 97) CreateGroup (2.0, 7.0, 97) CreateIndex (2.0, 7.0, 97) CreateObject (2.0, 7.0, 97) CreateProperty (2.0, 7.0, 97) CreateRelation (2.0, 7.0, 97) CreateTableDef (2.0, 7.0, 97) CreateUser (2.0, 7.0, 97) CreateWorkspace (2.0, 7.0, 97) CURRENCY
CurrentUser (2.0, 7.0, 97)
-D
DATABASE (2.0, 7.0, 97)
DATE (2.0, 7.0, 97)
DATETIME
DELETE
DESC
Description
DISALLOW
DISTINCT
DISTINCTROW
Document (2.0, 7.0, 97) DOUBLE (2.0, 7.0, 97)
DROP
-E
Echo (2.0, 7.0, 97)
Else
End
Eqv
Error
EXISTS (2.0, 7.0, 97)
Exit
-F
FALSE
Field, Fields (2.0, 7.0, 97) FillCache (2.0, 7.0, 97) FLOAT, FLOAT4, FLOAT8 FOREIGN (2.0, 7.0, 97)
Form, Forms
FROM
Full (2.0, 7.0, 97)
FUNCTION
-G
GENERAL
GetObject (2.0, 7.0, 97)
GetOption (2.0, 7.0, 97)
GotoPage
GROUP (2.0, 7.0, 97)
GROUP BY
GUID (7.0, 97)
-H
HAVING
-I[/color
Idle (2.0, 7.0, 97)
IEEEDOUBLE, IEEESINGLE
If
IGNORE (2.0, 7.0, 97)
Imp
IN, In
INDEX
Index, Indexes (2.0, 7.0, 97)
INNER
INSERT
InsertText (2.0, 7.0, 97)
INT, INTEGER, INTEGER1, INTEGER2, INTEGER4 INTO
IS, Is
-J
JOIN
-K
KEY (2.0, 7.0, 97)
-L
LEFT
Level
Like
LOGICAL, LOGICAL1
LONG, LONGBINARY, LONGTEXT
-M
Macro
Match (2.0, 7.0, 97)
Max, Min, Mod
MEMO
Module
MONEY
Move (2.0, 7.0, 97)
-
N
NAME (2.0, 7.0, 97) NewPassword (2.0, 7.0, 97)
NO
Not
NULL
NUMBER, NUMERIC
-O
Object (2.0, 7.0, 97) OLEOBJECT (2.0, 7.0, 97)
OFF
ON
OpenRecordset (2.0, 7.0, 97) OPTION
OR, Or
ORDER
Outer (2.0, 7.0, 97) OWNERACCESS
-P
Parameter (2.0, 7.0, 97) PARAMETERS
Partial (2.0, 7.0, 97)
PERCENT (2.0, 7.0, 97)
PIVOT
PRIMARY
PROCEDURE
Property (2.0, 7.0, 97)
-
Q
Queries
Query
Quit (2.0, 7.0, 97)
-R
REAL
Recalc (2.0, 7.0, 97)
Recordset (2.0, 7.0, 97) REFERENCES
Refresh
RefreshLink (2.0, 7.0, 97) RegisterDatabase (2.0, 7.0, 97) Relation (2.0, 7.0, 97)
Repaint (2.0, 7.0, 97) RepairDatabase (2.0, 7.0, 97) Report
Reports
Requery
RIGHT
-S
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论