Leni
Leni

Reputation: 683

Type mismatch in NotesDatabase.Search method using vb

I need to search a notes database with a set of given criteria using VB. I was going through IBM documentation at https://www.ibm.com/support/knowledgecenter/en/SSVRGU_9.0.1/basic/H_EXAMPLES_SEARCH_METHOD.html
and came up with below code as per example no. 3 there:

    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

But at notesDatabase.Search(Query, Nothing, 0) it gives me a runtime exception saying a type mismatch. Using Nothing and 0 for 2nd and 3rd arguments are fine as per https://www.ibm.com/support/knowledgecenter/it/SSVRGU_9.0.1/basic/H_SEARCH_METHOD.html

Therefore I suspect I am doing something wrong with first argument of

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

Can someone please tell me what I am doing wrong here?

Upvotes: 2

Views: 138

Answers (1)

Tode
Tode

Reputation: 12060

Your Formula is wrong. It needs to be

"Form = ""Project"""

In Addition the concept of "Nothing" seems to be different between the COM- Classes and vb.net as you found out when trying: You need to use a parameter of the right type. In your case:

New Runtime.InteropServices.UnknownWrapper(Nothing)

instead of simply

Nothing

as your second parameter.

Upvotes: 4

Related Questions