Foxtable(狐表)用户栏目专家坐堂 → 如何只保留最后一条记录


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

主题:如何只保留最后一条记录

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


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/4/21 10:43:00 [显示全部帖子]

参考代码

 

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "设备名"
For Each dr As DataRow In DataTables("测试").Select("", "设备名, 最后通信时间 desc")
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c).replace(" ","") <> dr(c).replace(" ", "") Then
                flag = True
                Exit For
            End If
        Next
        If flag Then
            If count > 1 Then
                idx &= idx_temp
            End If
            count = 1
            idx_temp = ""
        Else
            count += 1
            idx_temp &= dr("_Identify") & ","
        End If
    Else
        count += 1
    End If
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

 

Tables("测试").Filter = "_Identify not In (" & idx.trim(",") & ")"

'DataTables("测试").DeleteFor("_Identify not In (" & idx.trim(",") & ")")


 


 回到顶部