OpenDatabase

Metreos.Native.Database.OpenDatabase

Summary

OpenDatabase creates a named connection to a specific database instance which can then be subsequently used by the rest of the script instance.

Usage

OpenDatabase creates a connection with a name of your choosing, and associates that connection with your script instance. Subsequent Database API actions, such as ExecuteScalar, ExecuteQuery, and ExecuteCommand reference this connection by the same Name supplied in OpenDatabase.

Remarks

The underlying mechanism for communicating with the database is based on ADO.NET. Subsequently, the benefits of .NET connection pooling are inherent to the Database API methods. To maximize scalability of the connection pool, the OpenDatabase action does not keep the connection open. The connection is created, opened, and closed in rapid succession. By performing these set of operations, the OpenDatabase action will fail with Failure if there is a connectivity issue (i.e., if the database is down or if the connection string is wrong). However, if the connection is created and connected successfully, the newly-created database connection is put back into the pool.

There is no need to use OpenDatabase for databases defined in the Cisco Unified Application Designer as a script resource. In that case, the name of the database connection is the name of the database resource as defined in the Cisco Unified Application Designer.

When the script instance is destroyed, the connection created by the OpenDatabase action is disposed automatically.

Action Parameters
Parameter Name.NET TypeDefaultDescription
DSN *System.StringAn ADO.NET connection string formatted appropriately for the Type of database being connected to. You can use the FormatDSN action to help format this string.
Name *System.StringA name for this connection. This name must be used in all subsequent Database API methods in this script instance.
Type *Metreos.Utilities.Database+DbTypeoracleThe type of database to connect to. The following are the possible values:
oracle

Uses the .NET-provided Oracle Data Provider to connect to the database.

sqlserver

Uses the .NET-provided SQL Server Provider to connect to the database.

mysql

Uses the MySQL-provided Data Provider to connect to the database.

odbc

Uses the an ODBC data source to connect to the database.

No Result Data

Branch Conditions 

Success

No description.

Failure

No description.