使用vb在NotesDatabase.Search方法中键入不匹配

问题描述 投票:2回答:1

我需要使用VB使用一组给定的标准搜索注释数据库。我正在https://www.ibm.com/support/knowledgecenter/en/SSVRGU_9.0.1/basic/H_EXAMPLES_SEARCH_METHOD.html上阅读IBM文档 并根据示例编号提出了以下代码。 3那里:

    Dim notesSession As Object = CreateObject("lotus.NotesSession")
    notesSession.Initialize(Password)
    Dim notesDatabase As Object = notesSession.GETDATABASE(ServerName, DatabaseName)
    Dim Query as String = "{Form = Project}"
    Dim notesDocumentCollection As Object = notesDatabase.Search(Query, Nothing, 0)
    Dim notesDocument As Object = notesDocumentCollection.GetFirstDocument

但是在notesDatabase.Search(Query,Nothing,0)中,它给出了一个运行时异常,说明类型不匹配。根据https://www.ibm.com/support/knowledgecenter/it/SSVRGU_9.0.1/basic/H_SEARCH_METHOD.html,使用Nothing和0表示第二和第三个参数

因此,我怀疑我的第一个论点是做错了

notesDocumentCollection = notesDatabase .Search(formula $,notesDateTime,maxDocs%)

有人可以告诉我这里我做错了什么吗?

vb.net lotus-notes
1个回答
3
投票

你的公式错了。它需要

"Form = ""Project"""

另外,在尝试时发现COM-Classes和vb.net之间的“Nothing”概念似乎不同:您需要使用正确类型的参数。在你的情况下:

New Runtime.InteropServices.UnknownWrapper(Nothing)

而不是简单的

Nothing

作为你的第二个参数。

© www.soinside.com 2019 - 2024. All rights reserved.