我不明白! 我正在访问数据库中进行简单的插入。
static void EcrireDansBD()
{
//Connection a la BD
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;data source=me.mdb";
OleDbConnection conn = new OleDbConnection(connectionString);
//works
string sql = "INSERT INTO HQ_POINTS (NORD,EST,ELEV) VALUES (1,2,3)";
//Syntax error in INSERT INTO statement
string sql = "INSERT INTO HQ_POINTS (NORD,EST,ELEV,DESC) VALUES (1,2,3,'ok')";
//Syntax error in INSERT INTO statement
string sql = "INSERT INTO HQ_POINTS (NORD,EST,ELEV,DESC) VALUES (1,2,3,ok)";
//Syntax error in INSERT INTO statement
string sql = "INSERT INTO HQ_POINTS (NORD,EST,ELEV,DESC) VALUES (1,2,3,\"ok\")";
OleDbCommand cmd = new OleDbCommand(sql, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
这是表格:
alt text http://img1.imagilive.com/0810/Capturee43.PNG
帮助?
答案 0 :(得分:0)
DESC
是一个保留关键字,用于排序(ORDER BY column ASC/DESC
)。
你必须引用它:使用[DESC]
代替