Connecting to a Database

Many Essbase API functions (such as server administration, security, and outline maintenance) can be performed after the program has logged in. However, many database-related functions (for example, reporting or performing calculations) require that the program connect to a specific application and database. Use EsxSetActive() to identify a specific Essbase database. Logging in with EsxAutoLogin() also allows the identification of a specific database.

Note that the user must have sufficient privileges to access the database. A list of all applications and databases to which a particular user has access is returned by EsxLogin(), and can be obtained using EsxListDatabases().

If you connect to a database that is not running, Essbase automatically starts the database. It is not necessary to disconnect from a database. However, using the same login context handle to connect to another database will disconnect you from the original database. If you really need to be connected to two or more databases at once, your program needs to login multiple times (and manage each context handle independently).

/* C Example of connecting to a database */
ESS_STS_T       sts;
ESS_HCTX_T      hCtx;
ESS_APPNAME_T   AppName = "Sample";
ESS_DBNAME_T    DbName = "Basic";
ESS_ACCESS_T    Access;
sts = EssSetActive (hCtx, AppName, DbName, &Access);

' VB Example of connecting to a database
Dim     sts as ESB_STS_T
Dim     hCtx as ESB_HCTX_T
Dim     AppName as ESB_APPNAME_T
Dim     DbName as ESB_DBNAME_T
Dim     Access as ESB_ACCESS_T
AppName = "Sample"
DbName = "Basic"
sts = EsbSetActive (hCtx, AppName, DbName, Access)

The user's access level to the selected database is returned by EssSetActive (and by EsxAutoLogin()). This access level can be checked by using the security constant definitions that allow the application program to alter user options, by graying out menus, and so on.