openDatabase (NotesDbDirectory - JavaScript)

Opens a database.

Defined in

NotesDbDirectory

Syntax

openDatabase(dbfile:string) : NotesDatabase

openDatabase(dbfile:string, failover:boolean) : NotesDatabase

Parameter Description
dbfile The file name of the database to open.
failover If true and the database cannot be opened on the current server, an attempt is made to open it on another server in the cluster (if there is a cluster). The object Server and FilePath properties reflect the server on which the database is opened. For remote (IIOP) access, failover is always false.
Return value Description
NotesDatabase The opened database. An exception occurs if the database cannot be opened.

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();