以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  删除行自动更新  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=150877)

--  作者:swagger
--  发布时间:2020/6/9 20:36:00
--  删除行自动更新
表A:

If e.DataCol.Name = "编号" Then \'发生变化的是产品列.
  e.DataRow("数量") = DataTables("表B").Compute("Sum(数量)","[编号] = \'" & e.NewValue & "\'")

 End If 

表B的datarowdeleted:

Dim pr As DataRow = DataTables("表A").find("编号 = \'" & e.DataRow("编号") & "\'")    
If pr IsNot Nothing Then
    DataTables("表A").DataCols("编号").RaiseDataColChanged(pr)
End If


删除表B的行的时候出现错误,无法更新数据

详细错误信息:
调用的目标发生了异常。
此行已从表中移除并且没有任何数据。BeginEdit() 将允许在此行中创建新数据


这个该怎么解决?


--  作者:有点蓝
--  发布时间:2020/6/9 22:13:00
--  
表B的datarowdeleting:

Dim pr As DataRow = DataTables("表A").find("编号 = \'" & e.DataRow("编号") & "\'")    
If pr IsNot Nothing Then
e.DataRow("编号") = nothing
    DataTables("表A").DataCols("编号").RaiseDataColChanged(pr)
End If

去掉datarowdeleted事件