这是一段项目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
详细错误信息:
已添加了具有相同键的项。