Foxtable(狐表)用户栏目专家坐堂 → [求助]集合


  共有8808人关注过本帖树形打印复制链接

主题:[求助]集合

帅哥哟,离线,有人找我吗?
nblwar
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:977 积分:6806 威望:0 精华:1 注册:2012/8/7 22:03:00
[求助]集合  发帖心情 Post By:2012/12/13 10:31:00 [只看该作者]

如何将两个集合合并成一个不重复的集合

Dim Arys As List(Of String())  = DataTables("冷轧物流").GetUniqueValues("[熔铸编号] IS NOT NULL", "品种","合金","保税")
Dim Ary1s As List(Of String())  = DataTables("冷轧盘点表").GetUniqueValues("[熔铸编号] IS NOT NULL", "品种","合金","保税")

[此贴子已经被作者于2012-12-13 10:31:46编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
lin_hailun
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:6708 积分:34304 威望:0 精华:11 注册:2012/8/18 23:10:00
  发帖心情 Post By:2012/12/13 10:46:00 [只看该作者]

 简单的做法是,使用查询表联合两个表,然后获取。

Dim cmd As New SQLCommand
cmd.CommandText = "select a.第一列, a.第二列, a.第三列 from {表A}, {表B}"
Dim dt As DataTable = cmd.ExecuteReader
Dim ary As List(Of String()) = dt.GetUniqueValues("", "第一列", "第二列", "第三列")
msgbox(ary.count)
[此贴子已经被作者于2012-12-13 10:53:23编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
nblwar
  3楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:977 积分:6806 威望:0 精华:1 注册:2012/8/7 22:03:00
  发帖心情 Post By:2012/12/13 11:00:00 [只看该作者]

Dim Arys As List(Of String())  = DataTables("冷轧物流").GetUniqueValues("[熔铸编号] IS NOT NULL", "品种","合金","保税")
Dim Ary1s As List(Of String())  = DataTables("冷轧盘点表").GetUniqueValues("[熔铸编号] IS NOT NULL", "品种","合金","保税")
For Each Ary1 As String() In Ary1s
    If Arys.Contains(Ary1) = False Then
        Arys.Add(Ary1)
    End If
Next

 

为什么提取的会有重复的?? 其中品种跟保税两列有空值

[此贴子已经被作者于2012-12-13 11:02:59编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
lin_hailun
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:6708 积分:34304 威望:0 精华:11 注册:2012/8/18 23:10:00
  发帖心情 Post By:2012/12/13 11:30:00 [只看该作者]

Dim Ary1s As List(Of String())  = DataTables("冷轧物流").GetUniqueValues("[熔铸编号] IS NOT NULL", "品种","合金","保税")
Dim Ary2s As List(Of String())  = DataTables("冷轧盘点表").GetUniqueValues("[熔铸编号] IS NOT NULL", "品种","合金","保税")

Dim Ary3s As List(Of String())  = DataTables("冷轧物流").GetUniqueValues("[熔铸编号] IS NOT NULL", "品种","合金","保税")

For Each Ary2 As String() In Ary2s
    For Each Ary1 As String() In Ary1s
        For i As Integer = 0 To Ary1.Length
            If Ary1(i) <> Ary2(i) Then
                Ary3s.Add(Ary2)
                Exit For
            End If
        Next
    Next
Next

 回到顶部