老师好。窗体的表是sqltable,从Excel中导入数据,因需要进行复杂判断,用逐个单元格导入数据到狐表中。下面的代码,If d Is Nothing Then 判断语句没有起到作用:
For i As Integer = start To endrow
Dim zj As String = sheet(i,1).value '-------------------------------利用主机交易流水号,判断是否已经导入过
If zj <> "" Then
zj = zj.trim() '--------------------------------------------------删除空格
Dim d As DataRow = datatables(e.form.name & "_table1").SQLFind("主机交易流水号 = '" & zj & "'")
If d Is Nothing Then ' -------------------------------------- 没有导入过这个主机流水号
dim current as datarow = datatables(e.form.name & "_table1").addnew
Dim jyls As String = sheet(i,1).value
jyls = jyls.trim()
current("主机交易流水号") = jyls
。。。。。。。。
current.save
end if
end if
next
上面的代码,按理说不能重复导入同一个Excel表,因导入后,If d Is Nothing Then 会判断是否已经导入。但实际是可以重复导入
哪里有错误?请老师指点 谢谢!!
[此贴子已经被作者于2020/11/11 13:19:51编辑过]