以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  name 参数不能为空  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=196065)

--  作者:edisontsui
--  发布时间:2025/3/26 16:45:00
--  name 参数不能为空
Select Case e.DataCol.Name 
    Case "工序1完成人", "工序2完成人", "工序3完成人", "工序4完成人", "工序5完成人", "工序6完成人", "工序7完成人", "工序8完成人", "工序9完成人"
        e.DataRow.save
        Dim st1 As String = e.DataCol.Name
        Dim st3 As String
        Dim st4 As String
            st3 = st1.substring(0, 3) & "完成日期"
            st4 = st1.substring(0, 3) & "完成年月"
        If e.DataRow.isnull(e.DataCol.Name) Then
            e.DataRow(st3) = Nothing
            e.DataRow(st4) = Nothing
        Else 
            If e.DataRow.isnull(st1) = False Then
                If e.DataRow.isnull(st3) Then
                    e.DataRow(st3) = Date.today
                End If
            Else
                e.DataRow(st3) = Nothing
                e.DataRow(st4) = Nothing
            End If
        End If
        
        e.DataRow.save
End Select

老师,上面代码老是出现 “name 参数不能为空” 的提示,请问是哪里的问题呢?谢谢。

--  作者:有点蓝
--  发布时间:2025/3/26 17:01:00
--  
调试看是哪一句代码有问题
--  作者:edisontsui
--  发布时间:2025/3/27 7:44:00
--  
Select Case e.DataCol.Name 
    Case "工序1完成人", "工序2完成人", "工序3完成人", "工序4完成人", "工序5完成人", "工序6完成人", "工序7完成人", "工序8完成人", "工序9完成人"
        e.DataRow.save
        Dim st1 As String = e.DataCol.name
        Dim st3 As String
        Dim st4 As String
        st3 = st1.substring(0, 3) & "完成日期"
        st4 = st1.substring(0, 3) & "完成年月"
        If e.DataRow.isnull(e.DataCol.name) Then
            \'msgbox(2)  后面有问题
            e.DataRow(st3) = Nothing
            e.DataRow(st4) = Nothing
            \'msgbox(3) 前面有问题
        Else
            If e.DataRow.isnull(st1) = False Then
                If e.DataRow.isnull(st3) Then
                    e.DataRow(st3) = Date.today
                End If
            Else
                e.DataRow(st3) = Nothing
                e.DataRow(st4) = Nothing
            End If
        End If
        
        e.DataRow.save
End Select

当 newvalue 是空值的时候,在上面红色那部分代码会有提示。

--  作者:有点蓝
--  发布时间:2025/3/27 9:07:00
--  
调试

        If e.DataRow.isnull(e.DataCol.name) Then
            msgbox("st3=" & st3 & ",st4=" & st4)  后面有问题
            e.DataRow(st3) = Nothing
            e.DataRow(st4) = Nothing
            msgbox(3) 前面有问题
        Else

--  作者:edisontsui
--  发布时间:2025/3/27 9:39:00
--  
调试结果:st3=工序1完成日期, st4=工序1完成年月
然后出现如下提示:
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2022.8.18.1
错误所在事件:表,特采单排产,DataColChanged
详细错误信息:
调用的目标发生了异常。
“name”参数不能为空。
参数名: name

msgbox(3) 的 3 不会出现。


--  作者:有点蓝
--  发布时间:2025/3/27 9:43:00
--  
st3=工序1完成日期, st4=工序1完成年月】这两个列名正确吗?这2个列赋值会不会触发其它代码
--  作者:edisontsui
--  发布时间:2025/3/27 11:01:00
--  
果然是 工序1完成日期 会触发其他代码造成的。谢谢。