版主您好,我的代码是从XLS表中更新"联系人","座机","手机","地址"等列信息,但是我写的代码有些问题,我想实现只更新系统中的“联系人”列为空的行,同时XLS表中有的行而系统中没有的行不再新增。您看代码应该怎么写。谢谢
If User.IsRole("对公专区") Then
'审核代码
If msgbox("对账数据导入会覆盖已更新的联系人信息,是否进行导入?",65,"提示") = 1 Then
Dim Book As New XLS.Book("D:\khdaxt\drgx\dz.xls")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("对公客户明细").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 & "'")
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
Tables("对公客户明细").ResumeRedraw()
msgbox("对账数据导入完毕!",64,"提示")
End If
Else
MessageBox.Show("您无此权限!")
End If