有以下代码,以实现自动删除“表A” 的重复行 ,
由于本人学习水平有限,有个两问题,请狐爹耐心指导一二。
============================分割行========================
Dim dt As DataTable = DataTables("表A")
Dim hang As DataRow
With dt '开打锁行功能
.AllowLockRow = True
.AllowUnlockRow = True
End With
For i As Integer = 0 To dt.DataRows.count - 2 '遍历全部数据行
hang = dt.DataRows(i) '取当前行的值
hang.Locked = True '锁定当前行
dt.DeleteFor("[列1] = " & hang("列1") & " And " & "[列2] = " & hang("列2") …… ) '删除符合N项条件的行
hang.Locked = False '解锁当前行
Next
===========================分割线==========================
问题1:
第一次运行提示错误“Index was outside the bounds of the array.” ,再次运行正常, 何解?
问题2:
请狐爹传授下 ,其它更加科学、高效的方式,以及涉及到的主要命令语句