Connect to ODBC

Connects to an ODBC database.

Command availability: IBM RPA SaaS and IBM RPA on premises

Dependencies

You need a valid connection string to connect to the ODBC database.

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in RPA Studio's Script mode.

odbcConnect --connectionstring(String) (DbConnection)=connection

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Connection String connectionstring Required Text Connection string used to connect to the ODBC Database.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Connection connection Database Connection Variable that holds the connection to the ODBC database.

Example

This example connects to a database with the ODBC protocol by using the Assert Condition (assert) command to verify if the connection was successful. The message "Could not connect to the Database!" is displayed if the connection is empty.

defVar --name dbConnection --type DbConnection
// Connect to the database via the connection string and store the data in the connection variable.
odbcConnect --connectionstring "Driver={Microsoft Access Driver (*.mdb)}; Dbq=C:\\file.mdb; Uid=Admin; Pwd=; \r\n" dbConnection=connection
// Check if the connection was successful
assert --message "Could not connect to the database!" --left "${dbConnection}" --operator "Is_Null" --negate