为了账号安全,请及时绑定邮箱和手机立即绑定

LINQ TO SQL 删除操作时报错“找不到行或行已更改”

LINQ TO SQL 删除操作时报错“找不到行或行已更改”

当年话下 2018-12-07 07:24:40
表所有字段为非空 加载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 回答

?
青春有我

TA贡献1784条经验 获得超8个赞

是不是这行已经更改了啊 db.ENTUserAccount.DeleteOnSubmit(useraccount);

查看完整回答
反对 回复 2019-01-21
  • 3 回答
  • 0 关注
  • 867 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信