Examples: Creating a database

  1. This example creates a local database named SALES2.NSF. The database is not initialized. This database is useful for storing data programmatically but cannot be used through the Notes UI.
    Sub Initialize
      Dim db As New NotesDatabase("", "")  
      If db.IsOpen Then Messagebox "Is Open" Else Messagebox "Not open"
      Call db.Create("", "sales2.nsf", True)
      If db.IsOpen Then Messagebox "Is Open" Else Messagebox "Not open"
    End Sub
  2. This example creates a local database named saledisc.nsf based on the Domino template discuss4.ntf and changes the title. Discuss is the database object for the template and db is the database object for the new database. The third argument to CreateFromTemplate inherits design changes.
    Sub Initialize
      Dim discuss As New NotesDatabase("", "DISCUSS4.NTF")
      Dim db As NotesDatabase 
      Set db = discuss.CreateFromTemplate _
      ("", "SALEDISC", True) 
      db.Title = "Sales Discussion Database"
    End Sub
  3. This example creates a local replica of a database on a server and initializes it.
    Sub Initialize
      Dim names As New NotesDatabase("MARKET", "SALEDISC")
      Dim db As NotesDatabase 
      Set db = names.CreateReplica("", "SALEDISC")
      Messagebox db.Title
      If db.Replicate("MARKET") Then
        Messagebox "Replication successful"
      Else
        Messagebox "Replication not successful"
      End If
    End Sub
  4. This example creates a copy of names.nsf.
    Sub Initialize
      Dim names As New NotesDatabase("", "NAMES")
      Dim db As NotesDatabase
      Set db = names.CreateCopy("", "NAMESCPY")
    End Sub