Foxtable(狐表)用户栏目专家坐堂 → 删除重复行


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

主题:删除重复行

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


加好友 发短信
等级:八尾狐 帖子:1860 积分:5263 威望:0 精华:0 注册:2017/11/8 17:37:00
删除重复行  发帖心情 Post By:2022/10/12 23:14:00 [只看该作者]

'Dim i As Integer
'For i = DataTables("BOM清单").DataRows.Count - 1 To 0 Step - 1
'    Dim dr As DataRow = DataTables("BOM清单").DataRows(i) 
'        Dim dr2 As DataRow = DataTables("BOM清单").SQLFind("母件编码 = '" & dr("母件编码") & "' And 子件编码 = '" & dr("子件编码") & "' and _Identify > " & dr("_Identify"))
'        If dr2 IsNot Nothing Then
'            dr2.Delete
'        End If 
'Next

上面的代码用来删除重复行不起作用,不知是什么回事,不知是不是有超三行重复时不起作用

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


加好友 发短信
等级:超级版主 帖子:107783 积分:548260 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/10/13 8:47:00 [只看该作者]

Dim i As Integer
Dim dr1 As DataRow = DataTables("BOM清单").DataRows(DataTables("BOM清单").DataRows.Count - 1)
Dim dr As DataRow
For i = DataTables("BOM清单").DataRows.Count - 2 To 0 Step - 1
    dr = DataTables("BOM清单").DataRows(i)
    If dr("母件编码") = dr1("母件编码") AndAlso dr("子件编码") = dr1("子件编码") Then
        dr.delete
    Else
        DataTables("BOM清单").save
        DataTables("BOM清单").SQLDeleteFor("母件编码 = '" & dr1("母件编码") & "' And 子件编码 = '" & dr1("子件编码") & "' and _Identify <> " & dr1("_Identify"))
        dr1 = dr
    End If 
    
Next
DataTables("BOM清单").save
DataTables("BOM清单").SQLDeleteFor("母件编码 = '" & dr1("母件编码") & "' And 子件编码 = '" & dr1("子件编码") & "' and _Identify <> " & dr1("_Identify"))

 回到顶部