ConnectDB

Estimated reading: 5 minutes 1766 views

This activity helps the user to initiate a connection with the provided database server using a standard connection string. It is essential for processes that rely on database interactions, such as data extraction, transformation, loading, and reporting.

It acts as a scope where the output from the “ConnectDB” activity is used in other activities to automate SQL commands with the database, except for the “DSN” activity.

Properties

INPUT

AuthenticationMode: This parameter indicates to choose the authentication mode to connect with the database. Select the option from the drop-down:

 Windows: This mode allows the bot to connect to the database using the Windows credentials of the user.
SQL: In this mode, the bot connects to the SQL Server using a specific SQL Server login (username and password) created within the SQL Server instance.

DatabaseName*: This parameter indicates the name of the database to which the robot needs to establish a connection in order to automate processes.
It accepts values in “String” datatype. You can either enter the values hardcoded in “String” format or pass the values as “String” datatype.

DatabaseServer*: This parameter indicates the name of the server where the database is configured. The robot will establish a connection to this server to automate processes.
It accepts values in “String” datatype. You can either enter the values hardcoded in “String” format or pass the values as “String” datatype.

Password: This parameter indicates the password of the database to which the robot needs to establish a connection in order to automate processes.
It accepts values in “String” datatype. You can either enter the values hardcoded in “String” format or pass the values as “String” datatype.

Timeout: This parameter indicates the timeout value for establishing a connection to the database server. If the connection cannot be established within this specified time, it will throw an exception.

It accepts values in “String” datatype. You can either enter the values hardcoded in “String” format or pass the values as “String” datatype.

Username: This parameter indicates the username of the database to which the robot needs to access and establish a connection in order to automate processes.

It accepts values in “String” datatype. You can either enter the values hardcoded in “String” format or pass the values as “String” datatype.

MISC

DisplayName: Displays the name of the activity. The activity name can be customized, which aids in troubleshooting.

SkipOnError: Specify the “Boolean” value as “True” or “False.”

True: Continue executing the workflow regardless of any errors thrown.
False: Halt the workflow if it encounters any errors.
None: If the option is left blank, the activity will, by default, behave as if “False” were chosen.

Version: It indicates the version of the feature being used.

OUTPUT

Result: It provides the ability to view the execution status of the activity. It returns values in “Boolean.”

True: Indicates that the activity has been executed successfully without any errors.
False: Indicates that the activity has been unsuccessful due to an unexpected error being thrown.

SQLConnection: It helps to return the output as SQL connection which is required to automate with the other activities. It returns the values in “SQLConnection” datatype. (Refer the documentation below).

Represents mandatory fields to execute the workflow.

Here’s an example of how the activity is used in the workflow –

In the following example, I am going to use this activity to connect the Database and return the SQL connection as output to utilize it in the other activities.

Please note that in the following example, I have stored the credentials in a respective variable which is used in the example.

Steps to build the bot:

1. Create a solution.
2. Install the latest feature of “Database Automation” from the “Manage features”.
3. Drag and drop the “ConnectDB” activity into the workflow and set it as start node
4. Navigating to the “Authentication mode” in the properties, here I am choosing the value as “SQL” since I am authenticating my database with SQL credentials.
5. Now, moving on to the database server details, I have hardcoded the values in a variable
a. Here in the properties, (“Database name,” “Database server,” “Username,” and “Password”) i have added the variable respectively.
6. Next in the “Timeout” parameter, I am mentioning the value as “10000” seconds.
7. Moving to the “SqlConnection” in the output section of the properties to declare a variable here to view the output.
a. This step is crucial as it will be used as input in other activities except DSN activity. There are two ways to declare a variable –
b. Method 1: Double-click on the variable parameter in the Output section and enter a name that helps you easily identify the flow. Here, I’m using the name “DB_OUTPUT” and using the shortcut key “Ctrl+Q” to create the variable.
c. Method 2: Click on the variable pane, enter your preferred name. (here, I’m using “DB_OUTPUT”), and choose the data type as “BrowseForTypes”.
d. Select the value as “System.Data.Sqlclient.SqlConnection”.
8. Now, save and execute the workflow. You can view the state of the activity by declaring a variable in the “Result” properties.

Share this Doc

ConnectDB

Or copy link

CONTENTS