-- 回复:(moseser)[求助]如何删除重复的行?
Dim i As Integer
Dim dr1 As DataRow = DataTables("历史价格").DataRows(DataTables("历史价格").DataRows.Count - 1)
Dim dr As DataRow
For i = DataTables("历史价格").DataRows.Count - 2 To 0 Step - 1
dr = DataTables("历史价格").DataRows(i)
If dr("类别") = dr1("类别") AndAlso dr("名称") = dr1("名称") AndAlso dr("型号") = dr1("型号") AndAlso dr("单位") = dr1("单位") AndAlso dr("不含税单价") = dr1("不含税单价")AndAlso dr("所属项目") = dr1("所属项目") Then
dr.delete
Else
DataTables("历史价格").save
DataTables("历史价格").SQLDeleteFor( " 类别 = \'" & dr1("类别") & "\' and 名称 = \'" & dr1("名称") & "\' and 型号 = \'" & dr1("型号") & "\' 单位 = \'" & dr1("单位") & "\' 不含税单价 = \'" & dr1("不含税单价") & "\' and 所属项目 = \'" & dr1("所属项目") & "\' and _Identify <> \'" & dr1("_Identify") & "\' ")
dr1 = dr
End If
Next
DataTables("历史价格").save
DataTables("历史价格").SQLDeleteFor( " 类别 = \'" & dr1("类别") & "\' and 名称 = \'" & dr1("名称") & "\' and 型号 = \'" & dr1("型号") & "\' 单位 = \'" & dr1("单位") & "\' 不含税单价 = \'" & dr1("不含税单价") & "\' and 所属项目 = \'" & dr1("所属项目") & "\' and _Identify <> \'" & dr1("_Identify") & "\' ")