gpt4 book ai didi

lotus-notes - 将文档从 View 复制到其他数据库并将其删除

转载 作者:行者123 更新时间:2023-12-04 03:11:08 26 4
gpt4 key购买 nike

我想将文档从数据库中的 View 传输到其他数据库中的其他 View ,所以我必须复制然后删除文档,因为 notesdocument 的唯一选项是复制到数据库。

所以我有这段代码:

Option Public
Option Declare

Sub Initialize()

Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim dbB As New NotesDatabase(db.Server,"Desarrollo\Formular_CL02.nsf")
Dim vwA As NotesView
Dim vwB As NotesView
Dim docA As NotesDocument
Dim docB As NotesDocument

'Open the database
If Not (dbB.isopen) Then
Call dbB.open(db.Server,"Desarrollo\Formular_CL02.nsf")
End If

'Get the views
Set vwA = db.getView( "TestDevelop" )
Set vwB = dbB.getView( "TestDevelop" )

Set docA = vwA.GetFirstDocument
Do While Not( docA Is Nothing )
If docB Is Nothing Then
Call docA.CopyToDatabase(dbB)
Call docA.Remove(True)
End If
Set docA = vwA.GetNextDocument(docA)
Loop

End Sub

当我最后执行代理时,它显示了一个错误:

Function requires a valid ADT argument

如果我删除有关 Call docA.Remove(True) 的行,代理将毫无错误地复制所有文档。

有什么建议吗?

非常感谢!

最佳答案

您删除了 docA,然后您将无法获取下一个文档。

只需使用另一个“docNext”来保存这些信息:

Dim docNext as NotesDocument

Set docA = vwA.GetFirstDocument
Do While Not( docA Is Nothing )
Set docNext = vwA.GetNextDocument(docA)

If docB Is Nothing Then
Call docA.CopyToDatabase(dbB)
Call docA.Remove(True)
End If
Set docA = docNext
Loop

此外,在您的代码中始终有一个错误处理程序以至少获取有关错误的最少信息是一个好习惯:

第一行代码(在 End Sub 行之前):

On Error Goto ErrorHandler

代码结束:

EndSub:
Exit Sub
ErrorHandler:
Print Err & ", " & Error & " in line " & erl
Resume EndSub

您可以用消息框替换“打印”或发送电子邮件/写日志文档,等等。但至少你知道错误号、错误文本和错误行……

关于lotus-notes - 将文档从 View 复制到其他数据库并将其删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33913917/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com