那你还不如删除所有表数据,再重新添加数据,效率绝对比你查找数据要来得高
If msgbox("导入更新可以导入客户基础数据和最新的存款余额和年日均余额,是否进行?",65,"提示") = 1 Then
DataTables("对公客户明细").DataRows.Clear
Dim Book As New XLS.Book("D:\khdaxt\drgx\dgdrgx.xls")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
DataTables("对公客户明细").StopRedraw()
Dim nms() As String = {"账号","客户号","户名","账户性质","开户日期","存款余额","年日均余额"}
For n As Integer = 0 To Sheet.Rows.Count -1
Dim bh As String = sheet(n,0).Text
'Dim dr As DataRow = DataTables("对公客户明细").Find("账号 = '" & bh & "'")
Dim dr As DataRow = DataTables("对公客户明细").AddNew
If dr Is Nothing Then '如果不存在同编号的订单
dr = DataTables("对公客户明细").AddNew()
End If
For m As Integer = 0 To nms.Length -1
dr(nms(m)) = trim(Sheet(n,m).Value)
Next
Next
DataTables("对公客户明细").ResumeRedraw()
msgbox("客户数据导入更新完毕!",64,"提示")
End If