我的查询似乎在某处出错,但是对于我来说,如果有人可以欣赏一下,我似乎找不到它。香港专业教育学院试图谷歌搜索,看看是否有人遇到过同样的问题,但还没有运气。抱歉,如果它是重复的。
public static void InsertMake()
{
try
{
using (var conn = new SqlCeConnection(_connectionstring))
{
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
using (var command = new SqlCeCommand(@"INSERT INTO MAKE(description,lastupdatedone,is_deleted,on_server) VALUES (@Description, @DateTime, @Is_deleted, @On_server", conn))
{
command.Parameters.AddWithValue("@Description", Program.Form_mmm.textBoxMake.Text);
command.Parameters.AddWithValue("@DateTime", DateTime.Now);
command.Parameters.AddWithValue("@Is_deleted", 0);
command.Parameters.AddWithValue("@On_server", 0);
command.ExecuteNonQuery();
conn.Close();
}
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
错误消息是
(0x80004005)解析查询时出错。 [令牌行号= 1,令牌行偏移量= 114,令牌错误= @On_server]
答案 0 :(得分:5)
您在VALUES之后缺少右括号,但是您可能应该包含错误消息以100%确定是问题所在。
尝试更改此行
using (var command = new SqlCeCommand(@"INSERT INTO MAKE(description,lastupdatedone,is_deleted,on_server) VALUES (@Description, @DateTime, @Is_deleted, @On_server", conn))
对此
using (var command = new SqlCeCommand(@"INSERT INTO MAKE(description,lastupdatedone,is_deleted,on_server) VALUES (@Description, @DateTime, @Is_deleted, @On_server)", conn))