Execute an IDbCommand (that returns a 1x1 resultset) against the specified IDbTransaction using the provided parameters.

Namespace: CodeSmith.Engine
Assembly: CodeSmith.Engine (in CodeSmith.Engine.dll) Version: 6.0.0.0 (7.0.0.15127)

Syntax

C#
public virtual Object ExecuteScalar(
	IDbTransaction transaction,
	CommandType commandType,
	string commandText,
	params IDataParameter[] commandParameters
)
Visual Basic
Public Overridable Function ExecuteScalar ( 
	transaction As IDbTransaction,
	commandType As CommandType,
	commandText As String,
	ParamArray commandParameters As IDataParameter()
) As Object

Parameters

transaction
Type: System.Data..::..IDbTransaction
A valid IDbTransaction
commandType
Type: System.Data..::..CommandType
The CommandType (stored procedure, text, etc.)
commandText
Type: System..::..String
The stored procedure name or SQL command
commandParameters
Type: array<System.Data..::..IDataParameter>[]()[][]
An array of IDbParamters used to execute the command

Return Value

Type: Object
An object containing the value in the 1x1 resultset generated by the command

Exceptions

ExceptionCondition
System..::..InvalidOperationExceptionThrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
System..::..ArgumentNullExceptionThrown if commandText is null
System..::..ArgumentExceptionThrown if the parameter count does not match the number of values supplied
System..::..ArgumentNullExceptionThrown if transaction is null
System..::..ArgumentNullExceptionThrown if transaction.Connection is null

See Also