我想用一個值更新更新用戶表,但我無法弄清楚我做錯了什麼。這是我有什麼:使用LINQ上下文更新記錄?
public static void ApplyROB(string ROBread, string userName)
{
using (SERTEntities ctx = CommonSERT.GetSERTContext())
{
// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// Audit of the transfer
datUser trUser = new datUserRole();
trUser.ROB = ROBread;
trUser.AccountName = userName;
// Persist update to DB
ctx.SaveChanges();
}
}
我是否離開?當我點擊更新時沒有任何反應。 我怎麼說,在哪裏用戶名=用戶名?我做對了嗎?
基本上需要一個簡單的:
update datUser set ROB = "Y" where AccountName= "myusername"
它的轉向了更復雜一些在LINQ使用上下文
請幫助。
現在我收到錯誤。我必須走在正確的道路上(在沒有任何事情發生之前),但我怎麼知道這是做更新還是插入? –
你需要做更新?看修改後的答案... – spender
大獲成功!感謝大家的幫助! –