Examples: CreateDatabase method

This Visual Basic code creates a new database if it does not already exist.

Private Sub CreateDatabase_Click()
On Error GoTo errorHandler
Dim s As New NotesSession
s.Initialize
Dim dir As NotesDbDirectory
Dim db As NotesDatabase
Set dir = s.GetDbDirectory("")
Set db = dir.CreateDatabase("quack.nsf", True)
db.Title = "Ducks of North America"
MsgBox "Created database quack.nsf", , "Created database"
Exit Sub
errorHandler:
If Err.Number = NOTES_ERRORS.ERR_NOTES_ERROR2 Then
  MsgBox "Database quack.nsf already exists", , "Exists"
Else
  MsgBox Err.Description, , "Error " & Right(Hex(Err.Number), 4)
End If
End Sub