以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]帮诊断一下代码 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=91771) |
-- 作者:YDGJ2016 -- 发布时间:2016/10/18 17:22:00 -- [求助]帮诊断一下代码 这是一段项目AfterOpenProject事件中的代码: Dim dtb03 As DataTable Dim dtc02 As DataTable Dim cmdb03 As New SQLCommand Dim cmdc02 As New SQLCommand cmdb03.C cmdc02.C cmdb03.CommandText = "Select 前缀, Max(项目财务ID) As 项目财务ID Fr om {B03_项目信息} Group By 前缀" cmdc02.CommandText = "Select 前缀, Max(收据ID) As 收据ID Fr om {C02_业务收支} Group By 前缀" dtb03 = cmdb03.ExecuteReader dtc02 = cmdc02.ExecuteReader b03bhs.Clear() For Each drb03 As DataRow In dtb03.DataRows Dim qz1 As String = drb03("前缀") \'编号前缀 Dim bh1 As String = drb03("项目财务ID") Dim id1 As Integer If bh1.Length = 12 Then bh1 = bh1.SubString(7) If Integer.TryParse(bh1,id1) Then b03bhs.Add(qz1, id1) End If End If Next c02bhs.Clear() For Each drc02 As DataRow In dtc02.DataRows Dim qz2 As String = drc02("前缀") \'编号前缀 Dim bh2 As String = drc02("收据ID") Dim id2 As Integer If bh2.Length = 12 Then bh2 = bh2.SubString(7) If Integer.TryParse(bh2,id2) Then b03bhs.Add(qz2, id2) End If End If Next 运行会报错: .NET Framework 版本:2.0.50727.8689
Foxtable 版本:2016.7.29.1 错误所在事件:项目,AfterOpenProject 详细错误信息: 已添加了具有相同键的项。 |
-- 作者:YDGJ2016 -- 发布时间:2016/10/18 17:28:00 -- 是这样的,我的项目中有多个表都要自动生成编号,这段代码想通过OpenQQ避免在多人同时操作时产生重复的编号. |
-- 作者:有点蓝 -- 发布时间:2016/10/18 17:48:00 -- http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=91769 请不要重复发贴
|