尝试更新 SQL Server CE 失败
我的插入工作与我的 SQL Server CE 数据库运行良好,但我正在努力更新。
任何人都可以看到我正在尝试的内容有什么问题
using (SqlCeConnection con = new SqlCeConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString))
{
con.Open();
// Insert into the SqlCe table. ExecuteNonQuery is best for inserts.
string sql = "UPDATE SalesAssistant SET "
+ "(Name=@Name,IsEnabled=@IsEnabled,Role=@Role,LastModifiedDate=@LastModifiedDate,IsAdministrator=@IsAdministrator,PIN=@PIN,IsDeleted=@IsDeleted)" +
"WHERE SalesAssistantID=@SalesAssistantID";
using (SqlCeCommand com = new SqlCeCommand(sql, con))
{
com.Parameters.AddWithValue("@SalesAssistantID", em.ServerData.EmployeeID);
com.Parameters.AddWithValue("@Name", em.ServerData.EmployeeName);
com.Parameters.AddWithValue("@IsEnabled", em.ServerData.IsEnabled);
com.Parameters.AddWithValue("@LastModifiedDate", em.ServerData.LastModifiedDate);
com.Parameters.AddWithValue("@IsAdministrator", em.ServerData.IsAdministrator);
com.Parameters.AddWithValue("@IsDeleted", em.ServerData.IsDeleted);
com.Parameters.AddWithValue("@Role", em.ServerData.Role);
com.Parameters.AddWithValue("@PIN", em.ServerData.PIN);
com.ExecuteNonQuery();
}
}
我收到以下错误:
解析查询时出错。 [ 令牌行号 = 1,令牌行偏移量 = 27,错误令牌 = ( ]
I have the insert working fine with my SQL Server CE database however I am struggling to update.
Can anyone see whats wrong with what I am trying
using (SqlCeConnection con = new SqlCeConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString))
{
con.Open();
// Insert into the SqlCe table. ExecuteNonQuery is best for inserts.
string sql = "UPDATE SalesAssistant SET "
+ "(Name=@Name,IsEnabled=@IsEnabled,Role=@Role,LastModifiedDate=@LastModifiedDate,IsAdministrator=@IsAdministrator,PIN=@PIN,IsDeleted=@IsDeleted)" +
"WHERE SalesAssistantID=@SalesAssistantID";
using (SqlCeCommand com = new SqlCeCommand(sql, con))
{
com.Parameters.AddWithValue("@SalesAssistantID", em.ServerData.EmployeeID);
com.Parameters.AddWithValue("@Name", em.ServerData.EmployeeName);
com.Parameters.AddWithValue("@IsEnabled", em.ServerData.IsEnabled);
com.Parameters.AddWithValue("@LastModifiedDate", em.ServerData.LastModifiedDate);
com.Parameters.AddWithValue("@IsAdministrator", em.ServerData.IsAdministrator);
com.Parameters.AddWithValue("@IsDeleted", em.ServerData.IsDeleted);
com.Parameters.AddWithValue("@Role", em.ServerData.Role);
com.Parameters.AddWithValue("@PIN", em.ServerData.PIN);
com.ExecuteNonQuery();
}
}
I get the following error:
There was an error parsing the query. [ Token line number = 1,Token line offset = 27,Token in error = ( ]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
去掉SET列表两边的括号,即
Remove the parentheses around the SET list, i.e.