您现在的位置是:首页 > 电脑 > 

将文档从视图复制到其他数据库并将其删除(Copy documents from a view to other database and remove it)

2025-07-23 18:02:08
将文档从视图复制到其他数据库并将其删除(Copy documents from a view to other database and remove it) 我想将文档从数据库中的视图传输到其他数据库中的其他视图,因此我必须复制然后删除文档,因为notesdocument唯一的选项是copytodatabase。 所以我有这个代码: Option P
将文档从视图复制到其他数据库并将其删除(Copy documents from a view to other database and remove it)

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

所以我有这个代码:

Option Public Option Declare Sub Initialize() Dim session As ew otesSession Dim db As otesDatabase Set db = session.CurrentDatabase Dim dbB As ew otesDatabase(db.Server,"Desarrollo\Formular_") Dim vwA As otesView Dim vwB As otesView Dim docA As otesDocument Dim docB As otesDocument 'Open the database If ot (dbB.isopen) Then Call (db.Server,"Desarrollo\Formular_") End If 'Get the views Set vwA = db.getView( "TestDevelop" ) Set vwB = dbB.getView( "TestDevelop" ) Set docA = vwA.GetFirstDocument Do While ot( docA Is othing ) If docB Is othing Then Call docA.CopyToDatabase(dbB) Call docA.Remove(True) End If Set docA = vwA.GetextDocument(docA) Loop End Sub

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

Function requires a valid ADT argument

如果我删除关于调用docA.Remove(True)的行,代理将复制所有文档而不会出错。

有什么建议?

非常感谢!

I want to transfer the docs from a view in a database to other view in other database, so i have to copy and then to remove the docs, because the only option that notesdocument has is copytodatabase.

So i have this code:

Option Public Option Declare Sub Initialize() Dim session As ew otesSession Dim db As otesDatabase Set db = session.CurrentDatabase Dim dbB As ew otesDatabase(db.Server,"Desarrollo\Formular_") Dim vwA As otesView Dim vwB As otesView Dim docA As otesDocument Dim docB As otesDocument 'Open the database If ot (dbB.isopen) Then Call (db.Server,"Desarrollo\Formular_") End If 'Get the views Set vwA = db.getView( "TestDevelop" ) Set vwB = dbB.getView( "TestDevelop" ) Set docA = vwA.GetFirstDocument Do While ot( docA Is othing ) If docB Is othing Then Call docA.CopyToDatabase(dbB) Call docA.Remove(True) End If Set docA = vwA.GetextDocument(docA) Loop End Sub

When i execute the agent at the end it shows me an error:

Function requires a valid ADT argument

If i remove the line about Call docA.Remove(True) the agent will copy all documents without error.

Any advice?

Thanks a lot!

最满意答案

您删除docA然后您无法获得下一个文档。

只需使用另一个“docext”来保存信息:

Dim docext as otesDocument Set docA = vwA.GetFirstDocument Do While ot( docA Is othing ) Set docext = vwA.GetextDocument(docA) If docB Is othing Then Call docA.CopyToDatabase(dbB) Call docA.Remove(True) End If Set docA = docext Loop

另外,最好在代码中有一个错误处理程序,以获取有关错误的最少信息:

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

On Error Goto ErrorHandler

代码结束:

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

您可以用消息框替换“打印”,或者发送/写入日志文档,无论如何。 但至少你知道错误号,错误文本和错误行那样...

You delete docA and then you cannot get the next document.

Just use another "docext" to keep ther information:

Dim docext as otesDocument Set docA = vwA.GetFirstDocument Do While ot( docA Is othing ) Set docext = vwA.GetextDocument(docA) If docB Is othing Then Call docA.CopyToDatabase(dbB) Call docA.Remove(True) End If Set docA = docext Loop

In addition it is a good practice to ALWAYS have an errorhandler in your code to get at least a minimum information about the error:

First line of code (directly before the End Sub line):

On Error Goto ErrorHandler

End Of Code:

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

You can replace the "print" by a messagebox or send an email / write a log document, whatever. But at least you know the error number, error text and error line that way...

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/diannao/697391.html

相关标签:无
上传时间: 2023-08-27 09:52:07
留言与评论(共有 8 条评论)
本站网友 重庆肛肠医院
5分钟前 发表
因为notesdocument唯一的选项是copytodatabase
本站网友 武汉爱尔眼科医院
3分钟前 发表
但至少你知道错误号
本站网友 山茱萸的功效与作用
16分钟前 发表
"Desarrollo\Formular_") End If 'Get the views Set vwA = db.getView( "TestDevelop" ) Set vwB = dbB.getView( "TestDevelop" ) Set docA = vwA.GetFirstDocument Do While ot( docA Is othing ) If docB Is othing Then Call docA.CopyToDatabase(dbB) Call docA.Remove(True) End If Set docA = vwA.GetextDocument(docA) Loop End Sub When i execute the agent at the end it shows me an error
本站网友 乌灵胶囊的功效与作用
9分钟前 发表
EndSub
本站网友 cg模型下载
14分钟前 发表
Function requires a valid ADT argument If i remove the line about Call docA.Remove(True) the agent will copy all documents without error. Any advice? Thanks a lot! 最满意答案 您删除docA然后您无法获得下一个文档
本站网友 疳积草
2分钟前 发表
Exit Sub ErrorHandler
本站网友 金光华电影院
22分钟前 发表
但至少你知道错误号