Foxtable(狐表)用户栏目专家坐堂 → [求助]关于Filler语句的排除重复问题


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

主题:[求助]关于Filler语句的排除重复问题

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/8/1 11:19:00 [显示全部帖子]

 要用这种方法

 

Dim Cols1() As String = {"来源列一","来源列二","来源列三"}
Dim Cols2() As String = {"接收列一","接收列二","接收列三"}
For Each dr1 As DataRow In DataTables("表A").Select("")
    Dim dr2 As DataRow = DataTables("表B").find("第一列 = '" & dr1("第一列") & "' and 第二列 = '" & dr1("第二列") & "' and 第三列 = '" & dr1("第三列") & "'")
    If dr2 Is Nothing Then
        dr2 = DataTables("表B").AddNew()
    End If
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
Next


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/8/1 12:08:00 [显示全部帖子]

 实例发上来。


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/8/1 12:15:00 [显示全部帖子]

Dim Cols1() As String = {"第一列","第二列","第三列"}
Dim Cols2() As String = {"第一列","第二列","第三列"}
For Each dr1 As DataRow In DataTables("表A").Select("")
    Dim filter As String = "1=1"
    For i As Integer = 0 To cols1.length-1
        If dr1.IsNull(cols1(i)) Then
            filter &= " and " & cols2(i) & " is null"
        Else
            Dim dc As DataCol = DataTables("表B").datacols(cols2(i))
            If dc.IsString Then
                filter &= " and " & dc.name & " = '" & dr1(cols1(i)) & "'"
            ElseIf dc.IsBoolean Then
                filter &= " and " & dc.name & " = " & dr1(cols1(i))
            ElseIf dc.IsNumeric Then
                filter &= " and " & dc.name & " = " & dr1(cols1(i))
            ElseIf dc.IsDate Then
                filter &= " and " & dc.name & " = #" & dr1(cols1(i)) & "#"
            End If
        End If
    Next
    Dim dr2 As DataRow = DataTables("表B").find(filter)
    If dr2 Is Nothing Then
        dr2 = DataTables("表B").AddNew()
    End If
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
Next

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/8/1 18:51:00 [显示全部帖子]

 参考5楼代码。

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/8/3 10:26:00 [显示全部帖子]

 上传实例,贴出代码。

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/8/3 11:23:00 [显示全部帖子]

Dim Cols1() As String = {"T28CT","T28UT","T28DL","T28UserId","T28DeptId","T28PointId","F390","F391","F392","F394","F395","F396","F397","F398","F399","F400","F401","F402","F403","F404","F405","F406","F407","F408","F409","F410","F411","F412","F413","F414","F415","F416","F417","F418","F419","F420","F421","F422","F4367","F4368","F4370","F4371","F4372","F4373","F4374","F4375","F4376","F4377","F4378","F4379","F4380","F4381","F4382","F5140","F5221","F5222","F5223","F5224","F5225","F5226","F5299","F5308","F5310","F5311","F5312","F5313"}
Dim Cols2() As String = {"T246CT","T246UT","T246DL","T246UserId","T246DeptId","T246PointId","F4362","F4363","F4364","F4366","F4383","F4384","F4385","F4386","F4387","F4388","F4389","F4390","F4391","F4392","F4393","F4394","F4395","F4396","F4397","F4398","F4399","F4400","F4401","F4402","F4403","F4404","F4405","F4406","F4407","F4408","F4409","F4410","F4411","F4412","F4414","F4415","F4416","F4417","F4418","F4419","F4420","F4421","F4422","F4423","F4424","F4425","F4426","F5265","F5293","F5294","F5295","F5296","F5297","F5298","F5300","F5315","F5317","F5318","F5319","F5320"}
For Each dr1 As DataRow In DataTables("T28").Select("")
    Dim filter As String = "1=1"
    For i As Integer = 0 To cols1.length-1
        Dim dc As DataCol = DataTables("T246").datacols(cols2(i))
        If dr1.IsNull(cols1(i)) Then
            If dc.IsNumeric Then
                filter &= " and " & dc.name & " = " & dr1(cols1(i))
            Else
                filter &= " and " & cols2(i) & " is null"
            End If
        Else
            If dc.IsString Then
                filter &= " and " & dc.name & " = '" & dr1(cols1(i)) & "'"
            ElseIf dc.IsBoolean Then
                filter &= " and " & dc.name & " = " & dr1(cols1(i))
            ElseIf dc.IsNumeric Then
                filter &= " and " & dc.name & " = " & dr1(cols1(i))
            ElseIf dc.IsDate Then
                filter &= " and " & dc.name & " = #" & dr1(cols1(i)) & "#"
            End If
        End If
    Next
    Dim dr2 As DataRow = DataTables("T246").find(filter)
    If dr2 Is Nothing Then
        dr2 = DataTables("T246").AddNew()
    End If
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
Next
DataTables("T246").Save()

 


 回到顶部