2010-10-23 57 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