使用 vb 在 NotesDatabase.Search 方法中键入不匹配
Type mismatch in NotesDatabase.Search method using vb
我需要使用 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% )
有人可以告诉我我做错了什么吗?
你的公式是错误的。它需要
"Form = ""Project"""
此外,"Nothing" 的概念在 COM- 类 和 vb.net 之间似乎有所不同,正如您在尝试时发现的那样:您需要使用正确的参数类型。在你的情况下:
New Runtime.InteropServices.UnknownWrapper(Nothing)
而不是简单地
Nothing
作为你的第二个参数。
我需要使用 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% )
有人可以告诉我我做错了什么吗?
你的公式是错误的。它需要
"Form = ""Project"""
此外,"Nothing" 的概念在 COM- 类 和 vb.net 之间似乎有所不同,正如您在尝试时发现的那样:您需要使用正确的参数类型。在你的情况下:
New Runtime.InteropServices.UnknownWrapper(Nothing)
而不是简单地
Nothing
作为你的第二个参数。