createDatabase (NotesDbDirectory - JavaScript)

Creates a new database, using the server and file name that you specify.

Defined in

NotesDbDirectory

Syntax

createDatabase(dbfile:string) : NotesDatabase

createDatabase(dbfile:string, open:boolean) : NotesDatabase

Parameter Description
dbfile The file name of the new database.
open Specify true if you want to open the database and false if you do not.
Return value Description
NotesDatabase The new database.

Usage

Because the new database is not based on a template, it's blank and does not contain any forms or views.

Examples

This button creates a new database in the local directory if it does not already exist.
var dbdir:NotesDbDirectory = session.getDbDirectory(null);
var dbname:string = "newdb";
var dbtitle:string = "New database";
try {
	dbdir.openDatabase(dbname);
	requestScope.status = "Already exists: " + dbname;
	return;
} catch(e) {} // proceed if there is an error i.e. the database does not already exist
var db:NotesDatabase = dbdir.createDatabase(dbname);
var view:NotesView = db.createView("main"); // need at least 1 view to initialize database
db.setTitle(dbtitle);
requestScope.status = "Created " + db.getFileName();