以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  帮忙看看这个代码哪里出错了  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=88706)

--  作者:benwong2013
--  发布时间:2016/8/8 10:06:00
--  帮忙看看这个代码哪里出错了
If e.DataCol.Name = "菲尔人格分数" Then
    If e.DataRow.IsNull("菲尔人格分数") Then
        e.DataRow("结论") = Nothing
        e.DataRow("评语") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("T_PT_PhilQ").find("最高分 >= \'" & e.DataRow("菲尔人格分数") & "\' and 最低分 <= \'" & e.DataRow("菲尔人格分数") &"\'")
        e.DataRow("结论") = dr("结论")
        e.DataRow("评语") = dr("评语")
    End If
End If

当菲尔人格分数落在61-100区间的时候会出现这样的出错:
.NET Framework 版本:2.0.50727.5472
Foxtable 版本:2016.7.29.1
错误所在事件:表,T_PT_Phil,DataColChanged
详细错误信息:
调用的目标发生了异常。
未将对象引用设置到对象的实例。

图片点击可在新窗口打开查看此主题相关图片如下:34.png
图片点击可在新窗口打开查看



--  作者:大红袍
--  发布时间:2016/8/8 10:10:00
--  

1、最高分、最低分列,要改成数值列,不能是字符列

 

2、

 

If e.DataCol.Name = "菲尔人格分数" Then
    If e.DataRow.IsNull("菲尔人格分数") Then
        e.DataRow("结论") = Nothing
        e.DataRow("评语") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("T_PT_PhilQ").find("最高分 >= " & e.DataRow("菲尔人格分数") & " and 最低分 <= " & e.DataRow("菲尔人格分数"))
        If dr IsNot Nothing Then
            e.DataRow("结论") = dr("结论")
            e.DataRow("评语") = dr("评语")
        End If
    End If
End If