Ive been reading all the posts trying to solve this, and I did read all entries for “search” in the designer help.
I have a software db, I want to create a search that will search 2 or more knowledge databases and return results based on keyword.
Im having a problem searching more than one db at a time.
Using the following code I get “Database has not been opened yet” If I put in a callopen db I only get one db opened for searching…so what am I doing wrong.
'-- Notes DBs from which we search
Dim dbpath(2) As String
dbpath(0) = “Server1\KB1.nsf”
dbpath(1) = “Server1\KB2.nsf”
dbpath(2) = “Server2\KB3.nsf”
'-- Search all databases, calculating the total matches
For i = 0 To 2
'-- Open the database and update the index
Dim db As New NotesDatabase(“”, dbpath(i) )
Call db.UpdateFTIndex(True)
'-- Perform the Full Text Search and track the number of matching documents
Dim collection As NotesDocumentCollection
Set collection = db.FTSearch(doc.QueryText(0), 0 )
matchCount = matchCount + collection.count
Next i
Subject: Search 2 DBs for keyword - stuck on opening dbs
If your sample data for dbpath array is to be taken literally, part of your problem might be that you do not specify the server name in the 2nd parm when dimming New NotesDatabase. That should only be the file path and file name of the database. The server should go in the first parameter.
So if your databases are really on different servers, leaving the server parameter blank in your Dim New NotesDatabase will only check on the server the code is running on. Or local if you are running the code yourself.
The error you are getting about “database has not been opened yet” indicates that the database you were trying to process was not found at the specified location. Another thing you should do after instantiating NotesDatabase, is check to make sure the database is open for processing. Something like this:
If Not db.IsOpen Then
Msgbox "Error - cannot open database"
Exit Sub
End If
Hope that helps
Subject: RE: Search 2 DBs for keyword - stuck on opening dbs
Even when Im trying to run the code from a db on Server2 against 2 dbs also on Server2 I get the error.
If I use a calldb.open command I can open server\db, but not more than one can be assigned to “db”…
Can anyone give me help building an array for diff dbs to search from?
Subject: RE: Search 2 DBs for keyword - stuck on opening dbs
I tend to do something like this, which avoids hard-coding the array or database names. Adding a new database simply involves creating a new document in the list:
Set session = New NotesSession
Set dbcurr = session.CurrentDatabase
Set viewCurr = dbcurr.GetView( "(Lookup Active Database Listing)" ) ' the current list of active contracts
strServer = dbcurr.Server
Set viewdoc = viewCurr.GetFirstDocument
Dim view As NotesView
Dim doc As NotesDocument
Dim j As Integer
Dim filenum As Integer
Dim fname As String
Dim fpath As String
Dim pname As String
Dim paddress As String
Dim pncount As Integer
fpath = "c:\hospitals\"
While Not( viewDoc Is Nothing ) ' this loops through all the current databases in report central
Dim db As New NotesDatabase( strServer, viewDoc.DBPathName( 0 ) )
Dim strTitle As String
strTitle = db.Title
intlen = Len(strTitle) - 4
strTitle = Right(strTitle, intlen)
fname = fpath + strTitle + "_Hospital_Listing" + ".csv" 'May want to put this in the loop and create a file for each contract.
Set view = db.GetView("Provider_active")
'other code goes here
Set viewdoc = viewCurr.GetNextDocument(viewdoc)
Wend