contents   index   previous   next

Database connect()


database.connect(dbtype, server, username,



dbtype - A string representing the database type. Currently only "ODBC" is supported.


server - Data source name. On Windows systems using ODBC, this is specified in the ODBC Administrator Control Panel; on UNIX, in the .odbc.ini file. See your database or system administrator for more information.


username - Name of the user to connect to the database. Some relational database management systems (RDBMS) require that this be the same as your operating system login name; others maintain their own collections of valid user names. If in doubt, see your system administrator.


password - User's password. If the database does not require a password, use an empty string.



number - 0 if the call was successful; otherwise, a nonzero status code based on the error message produced by the database. If the method returns a nonzero status code, use the majorErrorCode and majorErrorMessage methods to interpret the meaning of the error.



Creates and caches a database connection to the specified database of the given type, using the username and password passed-in. When the connection goes out of scope, any pending transactions are rolled back. If any database connections are open when connect is called, they are closed and released before the new connection is opened.



#link <sedbc>, Database disconnect(), Database connected()



// This example creates a new database and

// then connects it to

// the database named "CLIENTS" using

// the username "ADMIN" and

// the password "admin-password"

var db = new database();

var err = db.connect("ODBC", "CLIENTS", "ADMIN",



Database connected()