Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共4 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助] 值不能为null,参数: key

1楼
洮沙 发表于:2025/2/9 11:12:00
DataColChanged事件如下代码,开发环境不报错,发布后偶发报如题错误,麻烦老师帮忙看一下,哪里错了,谢谢!
Select e.DataCol.Name
        Case "签订日期","合同种类"
            If e.DataRow.IsNull("签订日期") Or e.DataRow.IsNull("合同种类") Then
                e.DataRow("合同编号") = Nothing
            Else
                Dim d As Date = e.DataRow("签订日期")
                Dim y As Integer = d.Year
                Dim Days As Integer = Date.DaysInMonth(y,12)
                Dim fd As Date = New Date(y,1,1) '获得该年的第一天
                Dim ld As Date = New Date(y,12,Days) '获得该年的最后一天
                Dim bh As String = e.DataRow("合同种类") & "-" & Format(d,"yyyy") & "-" '生成合同编号的前缀
                If e.DataRow("合同编号").StartsWith(bh) = False '如果单据合同编号前缀不符
                    Dim flt As String
                    flt = "合同种类 = '" & e.DataRow("合同种类") & "' And 签订日期 >= '" & fd & "' And 签订日期 <= '" & ld & "' And [_Identify] <> " & e.DataRow("_Identify") 
                    Dim max1 As String
                    Dim max2 As String
                    max1 = e.DataTable.Compute("Max(合同编号)", flt) '取得该类别的最大编号
                    max2 = e.DataTable.SQLCompute("Max(合同编号)", flt) '取得该类别的最大编号
                    Dim idx1 As Integer 
                    Dim idx2 As Integer 
                    If max1 > "" Then '如果存在最大编号
                        idx1 = CInt(max1.Substring(bh.length, 4))
                    End If
                    If max2 > "" Then '如果存在最大编号
                        idx2 = CInt(max2.Substring(bh.length, 3))
                    End If
                    Dim idx As Integer = Math.Max(idx1, idx2)
                    idx = idx + 1 '获得最大编号加1
                    e.DataRow("合同编号") = bh & Format(idx, "0000")
                End If
            End If
    End Select
2楼
有点蓝 发表于:2025/2/9 20:12:00
看不出什么问题。确定是这个事件报错?截图看看错误详细信息
3楼
洮沙 发表于:2025/2/10 18:11:00
谢谢蓝老师!我把相关联代码全部检查并重写一遍,目前没有报错。
估计是窗口文本框(绑定到表“合同编号”)代码,
其中有一句代码:e.Sender.Value > ""
修改为:e.Sender.Text > ""
[此贴子已经被作者于2025/2/10 18:18:31编辑过]
4楼
有点蓝 发表于:2025/2/10 19:48:00
【值不能为null,参数: key】这个错误应该是字典添加的键为空值导致。检查用到字典的地方
共4 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02344 s, 2 queries.