Exception in syntax error of operating access datagram system. Data. oledb. oledbexception: insert into statement

Source: Internet
Author: User

Exception in syntax error of operating access datagram system. Data. oledb. oledbexception: insert into statement

In the past two days, I promised my friend to create a standalone version of the management system for him. Therefore, access is used for databases. In the past, SQL-server was used for development. However, they are all from Microsoft, so it should be okay to use them. However, when I insert data, the system reports system. Data. oledb. oledbexception: the syntax error of the insert into statement. Check the insert statement carefully and the "syntax error" cannot be found ",
Database Name: grade. MDB
Field: Cid char
Cname char
Note char
CodeAs follows:

# Region database connection

Public class dbconnection
{
Private oledbconnection conn;

Public oledbconnection oledbconn
{
Get
{
String Path = directory. getcurrentdirectory ();
String connstring = "provider = Microsoft. Jet. oledb.4.0;" +
"Data Source =" + path + "http://www.cnblogs.com/ForEverKissing/admin/file://grade.mdb ";
If (conn = NULL)
Conn = new oledbconnection (connstring );
Return conn;
}
}
}

# Endregion

// Insert new data
Public int addnewinfo ()
{
Oledbconnection myconn = dbconn. oledbconn;
Int val = 0;
Try
{
Myconn. open ();
String myinsertstring = "insert into collegeinfo (CID, cname, note)" +
"Values ('a11', 'aaa', 'bbb ')";
Oledbcommand cmd = new oledbcommand (myinsertstring, myconn );
Val = cmd. executenonquery ();
}
Catch (exception ex)
{
MessageBox. Show ("error:" + ex. tostring ());
Val =-1;
}
Finally
{
Myconn. Close ();
}
Return val;
}
When an exception is reported during running, I checked a lot of information on the Internet to find out the keyword of access when the field note is used. In SQL Server, the keyword can be used normally. If it is depressing, I only need to change the insert statement
Insert into collegeinfo (CID, cname, [note]) values ('a11', 'aaa', 'bbb ')
You can!

So I posted the problem. If a netizen encounters such a problem, you can check whether the field is a keyword.

---------------------------------
It seems that there are still a lot of access keywords. Thanks to songmeiying.

The following are Access Database keywords:

-
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
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
Bytes
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.