2010-10-23 131 views
1

我有我的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 " 
      + "([email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected])" + 
      "WHERE [email protected]"; 

    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(); 
    } 
} 

我收到以下错误:

There was an error parsing the query. [ Token line number = 1,Token line offset = 27,Token in error = (]

+0

而开始投票选择有用的答案。 – 2010-10-23 05:06:36

回答

2

周围的SET列表中删除括号,即

string sql = "UPDATE SalesAssistant SET " 
+ "[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]" + 
" WHERE [email protected]"; 
+0

感谢米奇靠近一点。 分析查询时发生错误。 [令牌行号= 1,令牌行偏移= 173,令牌出错= SalesAssistantID]} – 2010-10-23 04:50:04

+0

对不起我的错我错过了“WHERE” – 2010-10-23 04:52:09