ExecuteQuery
Execute ODBC query.
Task version: 3.0.0
Required Frends version: 5.7+
Required .NET version: 8.0
Compatible Agents: Crossplatform
Source code: https://github.com/FrendsPlatform/Frends.ODBC
Task Parameters
🗝ConnectionString : String
Connection string.
Default: -
Example: Driver={driver};Server=127.0.0.1,1433; Database=UnitTests;DSN=ODBC_testDB;Uid=sa;Pwd=yourStrong!Password;
Query : String
Query to be executed in string format.
Default: -
Example: SELECT * FROM MyTable WHERE ID = ?, INSERT INTO MyTable (id, first_name, last_name) VALUES (?, ?, ?),
ParametersInOrder : QueryParameter[]
Parameters for the database query.
Default: -
Example: [ { Value = "1" }, { Value = "Foo" } { Value = "Bar" } ]
ExecuteType : ExecuteTypes
Specifies how a command string is interpreted.
Auto: ExecuteReader for SELECT-query and NonQuery for UPDATE, INSERT, or DELETE statements.
ExecuteReader: Use this operation to execute any arbitrary SQL statements in SQL Server if you want the result set to be returned.
NonQuery: Use this operation to execute any arbitrary SQL statements in SQL Server if you do not want any result set to be returned. You can use this operation to create database objects or change data in a database by executing UPDATE, INSERT, or DELETE statements. The return value of this operation is of Int32 data type, and For the UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the SQL statement. For all other types of statements, the return value is -1.
Scalar: Use this operation to execute any arbitrary SQL statements in SQL Server to return a single value. This operation returns the value only in the first column of the first row in the result set returned by the SQL statement.
Possible values:
Auto: Specifies how a command string is interpreted.
Auto: ExecuteReader for SELECT-query and NonQuery for UPDATE, INSERT, or DELETE statements.
ExecuteReader: Use this operation to execute any arbitrary SQL statements in SQL Server if you want the result set to be returned.
NonQuery: Use this operation to execute any arbitrary SQL statements in SQL Server if you do not want any result set to be returned. You can use this operation to create database objects or change data in a database by executing UPDATE, INSERT, or DELETE statements. The return value of this operation is of Int32 data type, and For the UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the SQL statement. For all other types of statements, the return value is -1.
Scalar: Use this operation to execute any arbitrary SQL statements in SQL Server to return a single value. This operation returns the value only in the first column of the first row in the result set returned by the SQL statement.
NonQuery: Specifies how a command string is interpreted.
Auto: ExecuteReader for SELECT-query and NonQuery for UPDATE, INSERT, or DELETE statements.
ExecuteReader: Use this operation to execute any arbitrary SQL statements in SQL Server if you want the result set to be returned.
NonQuery: Use this operation to execute any arbitrary SQL statements in SQL Server if you do not want any result set to be returned. You can use this operation to create database objects or change data in a database by executing UPDATE, INSERT, or DELETE statements. The return value of this operation is of Int32 data type, and For the UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the SQL statement. For all other types of statements, the return value is -1.
Scalar: Use this operation to execute any arbitrary SQL statements in SQL Server to return a single value. This operation returns the value only in the first column of the first row in the result set returned by the SQL statement.
Scalar: Specifies how a command string is interpreted.
Auto: ExecuteReader for SELECT-query and NonQuery for UPDATE, INSERT, or DELETE statements.
ExecuteReader: Use this operation to execute any arbitrary SQL statements in SQL Server if you want the result set to be returned.
NonQuery: Use this operation to execute any arbitrary SQL statements in SQL Server if you do not want any result set to be returned. You can use this operation to create database objects or change data in a database by executing UPDATE, INSERT, or DELETE statements. The return value of this operation is of Int32 data type, and For the UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the SQL statement. For all other types of statements, the return value is -1.
Scalar: Use this operation to execute any arbitrary SQL statements in SQL Server to return a single value. This operation returns the value only in the first column of the first row in the result set returned by the SQL statement.
ExecuteReader: Specifies how a command string is interpreted.
Auto: ExecuteReader for SELECT-query and NonQuery for UPDATE, INSERT, or DELETE statements.
ExecuteReader: Use this operation to execute any arbitrary SQL statements in SQL Server if you want the result set to be returned.
NonQuery: Use this operation to execute any arbitrary SQL statements in SQL Server if you do not want any result set to be returned. You can use this operation to create database objects or change data in a database by executing UPDATE, INSERT, or DELETE statements. The return value of this operation is of Int32 data type, and For the UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the SQL statement. For all other types of statements, the return value is -1.
Scalar: Use this operation to execute any arbitrary SQL statements in SQL Server to return a single value. This operation returns the value only in the first column of the first row in the result set returned by the SQL statement.
Default: 3
Example: ExecuteType.ExecuteReader
ThrowErrorOnFailure : Boolean
(true) Throw an exception or (false) stop the Task and return result object containing Result.Success = false and Result.ErrorMessage = 'exception message'.
Default: True
Example: true
CommandTimeoutSeconds : Int32
Number of seconds for the operation to complete before it times out.
Default: 60
Example: 60
OutputMode : OutputMode
Output mode. Default is JToken.
DataReader is valid only for ExecuteReader queries.
For JToken output, the data is returned in Data property as a dynamic JToken type.
For DataReader output, the data is returned in DataReader property as OdbcDataReader type.
If using DataReader, remember to dispose task result at end of scope.
Possible values:
JToken: Output mode. Default is JToken.
DataReader is valid only for ExecuteReader queries.
For JToken output, the data is returned in Data property as a dynamic JToken type.
For DataReader output, the data is returned in DataReader property as OdbcDataReader type.
If using DataReader, remember to dispose task result at end of scope.
DataReader: Output mode. Default is JToken.
DataReader is valid only for ExecuteReader queries.
For JToken output, the data is returned in Data property as a dynamic JToken type.
For DataReader output, the data is returned in DataReader property as OdbcDataReader type.
If using DataReader, remember to dispose task result at end of scope.
Default: -
Example: JToken
Task Result
Success : Boolean
Operation complete without errors.
Example: true
RecordsAffected : Int32
Records affected. Some statements will return -1. See documentation of Input.ExecuteType for more information.
Example: 100
ErrorMessage : String
Error message. This value is generated when an exception occurs and Options.ThrowErrorOnFailure = false.
Example: Error occured...
Data : Object
Query result as JToken.
Example: Input.ExecuteType = ExecuteReader: [{"ID": "1","FIRST_NAME": "Saija","LAST_NAME": "Saijalainen","START_DATE": ""}], Input.ExecuteType = NonQuery: {{ "AffectedRows": -1 }}, Input.ExecuteType = Scalar: {{ "Value": 1 }}
DataReader : DataReaderWrapper
Gets the DataReaderWrapper instance when OutputMode is set to DataReader.
Example: DataReaderWrapper object
Task Changelog
Changelog for Task Frends.ODBC.ExecuteQuery.
[3.0.0] - 2026-02-18
Added
Added DataReaderWrapper class to encapsulate OdbcDataReader and avoid assembly reference issues when using DataReader output mode.
Result now implements IAsyncDisposable and exposes a DisposeAsync method for async resource cleanup.
Changed
[Breaking change] Updated target framework from net6.0 to net8.0.
[2.1.0] - 2025-03-25
Changed
Update packages: System.Data.Odbc 7.0.0 -> 9.0.3 coverlet.collector 3.1.2 -> 6.0.4 Microsoft.NET.Test.Sdk 17.1.0 -> 17.13.0 MSTest.TestAdapter 2.2.8 -> 3.8.3 MSTest.TestFramework 2.2.8 -> 3.8.3
[2.0.0] - 2024-09-13
Added
Breaking change - Support for returning data as a DataReader
The task now has an option field
OutputType
Security
Updated Newtonsoft.Json to 13.0.3
[1.0.0] - 2023-05-24
Added
Initial implementation
Last updated
Was this helpful?

