Foxtable(狐表)用户栏目专家坐堂 → 二数据表之间数据对比


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

主题:二数据表之间数据对比

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


加好友 发短信
等级:狐神 帖子:4650 积分:33912 威望:0 精华:0 注册:2008/8/31 22:44:00
  发帖心情 Post By:2012/7/24 6:48:00 [显示全部帖子]

Dim lst1 As New List(of DataRow)
Dim lst2 As New List(of DataRow)
For Each dr As DataRow In DataTables("学生名单1").DataRows
    If DataTables("学生名单2").Find("姓名 = '" & dr("姓名") & "'") Is Nothing Then
        lst1.Add(dr)
    Else
        lst2.Add(dr)
    End If
Next
For Each dr As DataRow In lst1 
    dr("对比结果") = "无此人"
Next
For Each dr As DataRow In lst2
    dr("对比结果") = ""
Next
For Each dr As DataRow In DataTables("学生名单2").DataRows
    If DataTables("学生名单1").Find("姓名 = '" & dr("姓名") & "'") Is Nothing Then
        lst1.Add(dr)
    Else
        lst2.Add(dr)
    End If
Next
For Each dr As DataRow In lst1 
    dr("对比结果") = "无此人"
Next
For Each dr As DataRow In lst2
    dr("对比结果") = ""
Next

或者

For Each dr As DataRow In DataTables("学生名单1").DataRows
    If DataTables("学生名单2").Find("姓名 = '" & dr("姓名") & "'") Is Nothing Then
        dr("对比结果") = "无此人"
    Else
        dr("对比结果") = ""
    End If
Next
For Each dr As DataRow In DataTables("学生名单2").DataRows
    If DataTables("学生名单1").Find("姓名 = '" & dr("姓名") & "'") Is Nothing Then
        dr("对比结果") = "无此人"
    Else
        dr("对比结果") = ""
    End If
Next


两者效率不同

另外还要表draw事件中设一下“红色显示”

 回到顶部