我将Excel工作表中的数据读入集合。数据已成功读取和存储。然后,我尝试使用ADODB对象将集合的内容写入SQL表,但由于某种原因,它无法正常工作,我想了解原因。这是重要的代码:
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseServer
strSQL = "<table name>"
rst.Open strSQL, Cnxn, adOpenKeyset, adLockBatchOptimistic, adCmdTableDirect
For Each row In copyRange.Rows
For Each cell In row.Cells
With cell
tempCol.Add (.Value)
End With
Next
strFind = tempCol.Item(2)
rst.Find strFind, 0, adSearchForward
If rst.EOF Then
MsgBox ("Entry not found, insert new entry")
rst.AddNew
rst!Date= tempCol(1)
rst!UID = tempCol(2)
rst!Field1= tempCol(3)
rst!Field2= tempCol(4)
rst!Field3= tempCol(5)
rst!Field4= tempCol(6)
rst!Field5= tempCol(7)
rst!Field6= tempCol(8)
rst.Update
Else
MsgBox ("Entry found, update existing")
rst!Fiedl4= tempCol(6)
rst!Field5= tempCol(7)
rst!Field6= tempCol(8)
rst.Update
End If
我收到&#34;条目未找到,插入新条目&#34;消息,但实际上没有任何内容写入SQL表,我不明白为什么?