Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > Database API > Methods

Database API: SetConnection() 

Scroll Prev Next More

 

Sets the current database connection. Recommended for use when working with multiple database connections.

 
All consequent API calls made via DB API functions will be executed via this connection. When working with the default (primary) connection the call of this function is not required.

 

To switch back to primary connection call this function without arguments.

Syntax

DB.SetConnection(name)

Arguments

name

the connection name, as it appears in wizard.

multiple_connections

Return value

No return value.

Example

 

// switch connection to Northwind
DB.SetConnection("Northwind");
 
// execute query
DB.Exec("update order set status='shipped' where OrderDate=CURDATE()");
 
// switch back to primary connection
DB.SetConnection("");

See also:

Database API: Exec()

Database API: LastId()

Database API: LastError()

Connecting to the database

About Database API