publicstaticint ExecuteNonQuery(SqlTransaction transaction, string spName, paramsobject[] parameterValues)
{
if( transaction ==null ) thrownew ArgumentNullException( "transaction" );
if( transaction !=null&& transaction.Connection ==null ) thrownew ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
if( spName ==null|| spName.Length ==0 ) thrownew ArgumentNullException( "spName" );
// If we receive parameter values, we need to figure out where they go if ((parameterValues !=null) && (parameterValues.Length >0))
{
// Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache) SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
// Assign the provided values to these parameters based on parameter order AssignParameterValues(commandParameters, parameterValues);
// Call the overload that takes an array of SqlParameters return ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName, commandParameters);
} else {
// Otherwise we can just call the SP without params return ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName);
} }