create connection string
Generate a connection string to a specified database.
Name | Description | Type | Modifier |
---|---|---|---|
variable | (Optional) Name of variable to receive the returned connection string. | String | None |
driver | (Optional) Name of the ODBC driver specified for the current connection. | String | None |
host | (Use only for DBMS sources, not Excel) DBMS server hostname or IP address. (Optionally, an instance name may also be appended, preceded with a backslash. Example: myhost\myinstance) | String | None |
port | (Optional for DBMS sources; not used for Excel) Port of DBMS server. Default Value: MSSQL use port 1433, MySQL uses port 3306. | String | None |
database name | (Optional) Name of database to be connected to. | String | None |
username | (Optional) Username with which to log on to database. | String | None |
password | (Optional) Password for database account specified by username. | String | None |
others | (Optional) Other connection string parameter(s) applicable to the host DBMS, in the form of key-value pairs separated by semicolons. | String | None |
Connection String
The following example illustrates the process of connecting to, and using, a database from within a test, of which creating a connection string is the first step.
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 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.
- If connecting to a MySQL database:
- If any of the associated execute sql calls are to contain multiple queries in their command arguments, the others argument must include the setting
Option=67108864;
. - If creating a Unicode-supported connection with the FreeTDS ODBC driver, others must contain
ClientCharset=UTF-8;
.
- If any of the associated execute sql calls are to contain multiple queries in their command arguments, the others argument must include the setting
- Use of a data source name (DSN) is supported. DSNs may be specified in the others argument with the following formats:
- User and System DSNs:
DSN=myDsn;
- File DSNs:
FILEDSN=c:\myDsnFile.dsn;
(Refer to Creating a Data Source Name (DSN) in Windows for further details)
- User and System DSNs:
- If the variable in argument variable has not been declared, the action creates it as a global.
- If the variable argument is left empty, TestArchitect supplies a global variable with the name _result.
- 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.