connect database
Open a database connection.
Name | Description | Type | Modifier |
---|---|---|---|
connection string | String used to open a database connection. | String | None |
name | Connection name (see below). | String | None |
None
The following example illustrates the process of connecting to, and using, a database from within a test. After creating a named connection string with the action create connection string, the string is used by this action to connect to the database.
variable driver host
create connection string Northwind_conn_strg SQL Server lgdn15031-w7d01
 
port database name username
>>> Northwind
 
password others
>>> Trusted_Connection=Yes
 
connection string name
connect database #Northwind_conn_strg Northwind_conn
 
name
use database Northwind_conn
 
command result
execute sql select ContactName from Customers where CustomerID='ABOUT' contactname_ds
- This action is generally invoked as part of a sequence of actions to allow the test to access a data source. (See Testing with databases for more information)
- The value for connection string may be derived by invoking the action create connection string. The nature of a connection string – that is, the parameters that apply to it – is specific to the type of data source that it targets. More information on connection strings is available from the website www.connectionstrings.com.
- You may establish multiple concurrent connections to different databases using separate invocations of this action. However, only one database connection may be in use at any given time.
- If connecting to a MySQL database:
- If any of the associated execute sql calls are to contain multiple queries in their command arguments, the setting
Option=67108864;
must be included in connection string. - If creating a Unicode-supported connection with the FreeTDS ODBC driver, the setting
ClientCharset=UTF-8;
must be present in connection string.
- If any of the associated execute sql calls are to contain multiple queries in their command arguments, the setting
- The name that you specify in argument name is assigned to the database connection and is available globally throughout your test run set, to be used by the built-in actions use database and disconnect database.
- This action supports the <ignore> modifier. If the string
<ignore>
is present as the value of any of the arguments, or any argument contains an expression that evaluates to<ignore>
, the action is skipped during execution.