表所有字段为非空
加载ID主键
protected void Page_Load(object sender, EventArgs e) { HRPaidTimeOffDataContext db = new HRPaidTimeOffDataContext(); ENTUserAccount useraccount= db.ENTUserAccount.Single(ua => ua.WindowsAccountName == @"VARALLO1\VaralloMadison");
ViewState["ENTUserAccountID"] = useraccount.ENTUserAccountID; }
执行删除:
protected void Button4_Click(object sender, EventArgs e) { HRPaidTimeOffDataContext db = new HRPaidTimeOffDataContext(); try { db.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict); }
catch (System.Data.Linq.ChangeConflictException ex) { foreach (System.Data.Linq.ObjectChangeConflict occ in db.ChangeConflicts) { occ.Resolve(System.Data.Linq.RefreshMode.OverwriteCurrentValues); } } ENTUserAccount useraccount = new ENTUserAccount();
useraccount.ENTUserAccountID = Convert.ToInt32(ViewState["ENTUserAccountID"]);
db.ENTUserAccount.Attach(useraccount); db.ENTUserAccount.DeleteOnSubmit(useraccount); db.SubmitChanges();//此处报错“找不到行或行已更改”
}
没做更新,是否删除也要添加时间戳?
- 3 回答
- 0 关注
- 867 浏览
添加回答
举报
0/150
提交
取消