以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助] (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=91769) |
-- 作者:YDGJ2016 -- 发布时间:2016/10/18 16:43:00 -- [求助] .NET Framework 版本:2.0.50727.8689 Foxtable 版本:2016.7.29.1 错误所在事件:项目,AfterOpenProject 详细错误信息: 已添加了具有相同键的项。 |
-- 作者:有点蓝 -- 发布时间:2016/10/18 16:57:00 -- 错误所在事件:项目,AfterOpenProject 代码放出来
|
-- 作者:YDGJ2016 -- 发布时间:2016/10/18 17:01:00 -- 代码怎么发不了呢? |
-- 作者:有点蓝 -- 发布时间:2016/10/18 17:11:00 -- http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=69632 |
-- 作者:YDGJ2016 -- 发布时间:2016/10/18 17:20:00 -- 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 |
-- 作者:有点蓝 -- 发布时间:2016/10/18 17:34:00 -- 表{B03_项目信息}和 {C02_业务收支} 有重复的前缀 |
-- 作者:YDGJ2016 -- 发布时间:2016/10/18 18:05:00 -- 是不是改了列名就可以了? |
-- 作者:YDGJ2016 -- 发布时间:2016/10/18 18:06:00 -- 我把列名改过,还是同样的报错。 |
-- 作者:有点蓝 -- 发布时间:2016/10/18 20:13:00 -- 跟列名没有关系的,是这2列里面存储的数据有重复项 |
-- 作者:YDGJ2016 -- 发布时间:2016/10/18 20:18:00 -- 改成下面这样,还是同样的报错: 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 前缀B03, Max(项目财务ID) As 项目财务ID Fr om {B03_项目信息} Group By 前缀B03" cmdc02.CommandText = "Select 前缀C02, Max(收据ID) As 收据ID Fr om {C02_业务收支} Group By 前缀C02" dtb03 = cmdb03.ExecuteReader dtc02 = cmdc02.ExecuteReader b03bhs.Clear() For Each drb03 As DataRow In dtb03.DataRows Dim qz1 As String = drb03("前缀B03") \'编号前缀 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("前缀C02") \'编号前缀 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 |