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.
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
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
|
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
|
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
-
Open a workflow or create a new workflow.
-
Drag the ExecuteNonQuery activity into your workflow.
-
Specify the values for the input arguments or map them to workflow variables.
-
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.
-
Configure the output argument in the activity named TotalRowsAffected to the new workflow variable RowsAffectedCount.
-
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