Examples: GetDatabase method

  1. This agent gets a database and tests the resulting NotesDatabase object with IsOpen to ensure that the database exists and can be opened.
    Sub Initialize
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Set db = s.GetDatabase("snapper", "names2")
      If Not db.IsOpen Then
        Messagebox "names2.nsf does not exist on snapper",, _
        "No names2.nsf"
      Else
        Messagebox db.Title,, "Title of names2.nsf"
      End If
    End Sub
  2. This agent gets a database, creating a NotesDatabase object only if the database exists and can be opened. The agent tests to see if the NotesDatabase object was created.
    Sub Initialize
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Set db = s.GetDatabase("snapper", "names2", False)
      If db Is Nothing Then
        Messagebox "names2.nsf does not exist on snapper"
      Else
        Messagebox db.Title,, "Title of names2.nsf"
      End If
    End Sub