以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]两表判断是否重复添加新表  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=77277)

--  作者:vvfree
--  发布时间:2015/11/15 0:11:00
--  [求助]两表判断是否重复添加新表
比如有 表(A ) 表(B ) ,表(C)  想用”表(B)“行 判断 ”表(A)“的数据行是否重复,把表(B)不重复  “表(A)”的行添加到 “表(C)”
--  作者:大红袍
--  发布时间:2015/11/15 10:32:00
--  
Dim Cols1() As String = {"来源列一","来源列二","来源列三"}
Dim Cols2() As String = {"接收列一","接收列二","接收列三"}
For Each dr1 As DataRow In DataTables("表B").Select("")
    Dim dr2 As DataRow = DataTables("表A").find("第一列 = \'" & dr1("第一列") & "\'")
    If dr2 Is Nothing Then
        dr2 = DataTables("表C").AddNew
        For i As Integer = 0 To Cols1.Length -1
            dr2(Cols2(i)) = dr1(Cols1(i))
        Next
    End If
Next