Mediachase FileUploader.NET 1.9 Framework Help

SqlHelper.ExecuteScalar Method (SqlTransaction, CommandType, String, SqlParameter[])

Execute a SqlCommand (that returns a 1x1 resultset) against the specified SqlTransaction using the provided parameters.

[Visual Basic]
Overloads Public Shared Function ExecuteScalar( _
   ByVal transaction As SqlTransaction, _
   ByVal commandType As CommandType, _
   ByVal commandText As String, _
   ParamArray commandParameters As SqlParameter() _
) As Object
[C#]
public static object ExecuteScalar(
   SqlTransaction transaction,
   CommandType commandType,
   string commandText,
   params SqlParameter[] commandParameters
);

Parameters

transaction
a valid SqlTransaction
commandType
the CommandType (stored procedure, text, etc.)
commandText
the stored procedure name or T-SQL command
commandParameters
an array of SqlParamters used to execute the command

Return Value

an object containing the value in the 1x1 resultset generated by the command

Remarks

e.g.: int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24));

See Also

SqlHelper Class | Mediachase.FileUploader Namespace | SqlHelper.ExecuteScalar Overload List