以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助] 提示引用问题,请问错在哪呢  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=97968)

--  作者:riancel
--  发布时间:2017/3/21 22:18:00
--  [求助] 提示引用问题,请问错在哪呢
每新增行时,第一次录入会出错,但后面更改此列触发事件又完全正常
提示:.NET Framework 版本:2.0.50727.5485
Foxtable 版本:2017.3.18.1
错误所在事件:表,shoufeimx,DataColChanged
详细错误信息:
调用的目标发生了异常。
未将对象引用设置到对象的实例。
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:学校收费系统foxtable2.table


问题好像是出在最后四行

整个变更列触发事件的代码如下:
If e.DataRow("printer") = True And e.DataCol.Name = "printer"  Then
\'-------------------------------------------打印后回写流水表
Dim nma() As String = {"riqi","fs-pjhm","xuehao","xingming","fsjine","zuofei","shoukuanren","xuehao"} \'A表数据来源列
    Dim nmb() As String = {"riqi","pjhm","xuehao","xingming","jine","zuofei","shoukuanren","qianru"} \'B表数据接收列
    Dim dr As DataRow = DataTables("shoufeiliushui").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
Next
Dim nmc() As String = {"riqi","wl-pjhm","xuehao","xingming","wljine","zuofei","shoukuanren","xuehao"} \'A表数据来源列
    Dim nmd() As String = {"riqi","pjhm","xuehao","xingming","jine","zuofei","shoukuanren","qianru"} \'B表数据接收列
    Dim drr As DataRow = DataTables("shoufeiliushui").AddNew
    For j As Integer = 0 To nmc.Length - 1
        drr(nmd(j)) = e.DataRow(nmc(j))
Next
Else If e.DataCol.Name = "zuofei" Then
\'-------------------------------------------作废后回写流水表 
Dim dr As DataRow = DataTables("shoufeiliushui").Find("pjhm = \'" & e.DataRow("fs-pjhm") & "\'")
    dr("zuofei") = e.DataRow("zuofei")
Dim dr2 As DataRow = DataTables("shoufeiliushui").Find("pjhm = \'" & e.DataRow("wl-pjhm") & "\'")
    dr2("zuofei") = e.DataRow("zuofei")
End If
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:学校收费系统foxtable2.table


--  作者:有点蓝
--  发布时间:2017/3/21 22:42:00
--  
Find之后要判断一下再用

Dim dr As DataRow = DataTables("shoufeiliushui").Find("pjhm = \'" & e.DataRow("fs-pjhm") & "\'")
if dr isnot nothing
    \'其它后续代码
endif