ExecuteNonQuery

The ExecuteNonQuery activity enables you to execute SQL statements that INSERT, UPDATE, or DELETE data in a given data source. For more information, see ExecuteNonQuery Example.

ExecuteNonQuery

alert

In general, the connection strings used during workflow execution are retrieved from the web.config of the product that triggers workflow execution.

Only if you want to run a workflow with ExecuteDataReader, ExecuteNonQuery, or ExecuteQuery activity in test mode using the Run option in Workflow Composer, would you need to manually add the connection string to the Workflow Composer web.config file.

Properties

ExecuteNonQuery Properties
Property Value Required Notes
CommandText InArgument<String> Yes Enter a command that specifies the activity to perform on the target data source – and should not be expected to return a result set. This activity allows commands that INSERT, UPDATE, or DELETE records in the target database.

Example

INSERT INTO Messages (Message)
VALUES ('New message added')

ConnectionString InArgument<String> Yes Enter the name of a connection string that has been configured in the CONFIG file of the host application that is executing the workflows (see Connection Strings).

If none is specified, this activity attempts to connect to a connection string named “DbConnection”.

Connection String Example

"dbSampleData"

DisplayName String No Specify a name for the activity or accept the default.
TotalRowsAffected OutArgument<Int32> Yes The output argument contains the total number of rows affected by the execution of the SQL command in the database.

Example

If a DELETE command was entered as input argument and 12 rows were deleted from a table, the resulting value is '12'.

ExecuteNonQuery Example

  1. Open a workflow or create a new workflow.

  2. Drag the ExecuteNonQuery activity into your workflow.

  3. Specify the values for the input arguments or map them to workflow variables.

    ExecuteNonQuery Example

  4. Create a workflow variable of data type Int32 that will be mapped to the result of the query execution.

    In this example, we created a new variable called RowsAffectedCount.

    ExecuteNonQuery Variable

  5. Configure the output argument in the activity named TotalRowsAffected to the new workflow variable RowsAffectedCount.

    ExecuteNonQuery: OutArgument mapped to variable

  6. Run the workflow.

    Result: If the query successfully connects to the data source, it populates your local variable with the total rows affected by the query.

To see how this activity can be used in a workflow, refer to