Run ExecuteNonQuery, ExecuteReader, and ExecuteScalar Operations using the SQL adapter

The Microsoft BizTalk Adapter for SQL Server exposes the following operations at the root level:

  • ExecuteNonQuery: 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.

  • ExecuteReader: Use this operation to execute any arbitrary SQL statements in SQL Server if you want the result set to be returned, if any, as an array of DataSet. For information about DataSet, see “DataSet Class” at https://go.microsoft.com/fwlink/?LinkID=196853.

  • ExecuteScalar: 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.

    Note

    The advantage of ExecuteScalar over ExecuteReader is that the response message payload of the ExecuteScalar operation is much smaller compared to the one returned by the ExecuteReader operation. Therefore, if you require only one value to be returned, you should use ExecuteScalar instead of ExecuteReader.

    You can use the ExecuteNonQuery, ExecuteReader or ExecuteScalar operation to execute multiple SQL statements.

    For more information about performing these operations using the BizTalk Server, see ExecuteReader, ExecuteScalar, or ExecuteNonQuery Operations by Using BizTalk Server.

See Also

What Operations Can be Performed Using the Adapter?