FYI - Problem with using New NotesDatabase method

FYI -

While troubleshooting a client’s agent LotusScript code running on Domino 6.03 RedHat 8.0 (2.14-18), we discovered the following:

They were using the Set notesDatabase = New NotesDatabase( server$, dbfile$ ) to open an existing database on another server. This worked intermittently. They were getting this error in their log.nsf

Agent ‘agentname’ error: Database server!!sales\targetclass\database.nsf has not been opened yet

This was fixed with two changes:

  1. We changed the LotusScript to use this method

Set notesDatabase = notesSession.GetDatabase( server$, dbfile$)

note: consider adding Is.Open property of the Database class if appropriate

  1. and we found that we needed to change the case of targetclass to targetClass…as this was also causing problems. The folder as it was created on their server was targetClass.

Hope this helps someone.

Subject: FYI - Problem with using New NotesDatabase method

It is hard to accept this because we only have a snippet of the code.

Here is a simple agent I wrote to test the opening of a database on a different server:

Dim session As New NotesSession

Dim Db As NotesDatabase, otherdb As NotesDatabase, doc As NotesDocument, view As NotesView

Dim ServerNameString As String

ServerNameString = "ServerName/OrgName"

Set db = session.CurrentDatabase

Set otherdb = New NotesDatabase(ServerNameString, "log.nsf")

If Not(otherdb.Title = "") Then

	Msgbox "got a database on " & ServerNameString

	Set view = otherdb.GetView("Miscellaneous Events")

	Msgbox "got view"

	Set doc = view.GetFirstDocument

	Msgbox "got a doc"

	If Not(doc Is Nothing) Then

		Msgbox "got doc " & doc.Created & " was when it was created."

	End If

End If 

As you can see I am using the method you are reporting as an error.

HTH – Cheers

Subject: RE: FYI - Problem with using New NotesDatabase method

Hi Joe,

How do I use this agent? Where do I save it at? I am pretty new to Lotus Notes.

Thanks for your help.

DN

Subject: FYI - Problem with using New NotesDatabase method

Thanks - don’t panic, these are known “gotchas”: as you’ve discovered, you should always test a NotesDatabase object to check that it’s actually open; if you’ve not opened it before, and don’t do an explicit test, you get the error you’re experiencing.

The other one’s a doozie: Linux / Unix based OSes are case sensitive!

Hope all goes well with your app.