运行这段代码时总报错为"Variant does not contain a container"是什么原因?
多谢了!!!
代码如下:
Set session = New NotesSession
Set con= New ODBCConnection
Set db = session.CurrentDataBase ' 取到当前数据库的信息
Set qry = New ODBCQuery
Set result = New ODBCResultSet
'Msgbox "1111111111111111"
If Con.ConnectTo("test","system","manager") Then
'Msgbox "22222222222222"
Set qry.Connection = con
qry.SQL = "SELECT * FROM abcd"
Set result.Query = qry
Call result.Execute()
Set dc = db.AllDocuments ' 得到当前数据库中所有文档的文档集
'Msgbox "new1"
If dc.Count = 0 Then ' 如果文档集为空,则直接退出
result.Close(DB_CLOSE)
con.Disconnect
Msgbox"com.disconnect"
Exit Sub
End If
For i = 1 To dc.Count ' 循环, 直到所有文档都被写入关系库
'For i = 1 To 5 ' 循环, 直到所有文档都被写入关系库
Set doc = dc.GetNthDocument(i) '获得第i条文档
'Msgbox "333333333333333333"
Call result.AddRow() ' 在关系库中增加一条记录
Forall j In doc.Items
Dim str_name As String
Dim value As Variant
str_name = j.name
If (str_name<> "Form")And (str_name<> "$UpdatedBy") Then ' Notes为每个文档都增加了两个特殊的notesItem
'对象用于标识系统信息
value = doc.GetItemValue(str_name)
Call result.SetValue(str_name,value(0)) ' 为关系库中的字段赋值
End If
End Forall
result.UpdateRow ' 更新关系库
Next
result.Close(DB_CLOSE)
con.Disconnect
Else
Messagebox("Could not connect server")
End If
3 个解决方案
#1
up
#2
加入错误调试信息,看看是哪个Object没有定义.
#3
http://211.95.79.143/we/help/download/OutData.rar
#1
up
#2
加入错误调试信息,看看是哪个Object没有定义.
#3
http://211.95.79.143/we/help/download/OutData.rar