Esempio n. 1
0
        /// <summary>
        /// The execute reader.
        /// </summary>
        /// <param name="transaction">
        /// The transaction.
        /// </param>
        /// <param name="spName">
        /// The sp name.
        /// </param>
        /// <param name="parameterValues">
        /// The parameter values.
        /// </param>
        /// <returns>
        /// The <see cref="OleDbDataReader"/>.
        /// </returns>
        public static OleDbDataReader ExecuteReader(
            OleDbTransaction transaction,
            string spName,
            params object[] parameterValues)
        {
            // if we got parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                OleDbParameter[] commandParameters =
                    OledbHelperParameterCache.GetSpParameterSet(transaction.Connection.ConnectionString, spName);

                AssignParameterValues(commandParameters, parameterValues);

                return(ExecuteReader(transaction, CommandType.StoredProcedure, spName, commandParameters));
            }

            // otherwise we can just call the SP without params
            return(ExecuteReader(transaction, CommandType.StoredProcedure, spName));
        }
Esempio n. 2
0
        /// <summary>
        /// The execute non query.
        /// </summary>
        /// <param name="transaction">
        /// The transaction.
        /// </param>
        /// <param name="spName">
        /// The sp name.
        /// </param>
        /// <param name="parameterValues">
        /// The parameter values.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public static int ExecuteNonQuery(OleDbTransaction transaction, string spName, params object[] parameterValues)
        {
            // if we got 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 & populet the cache)
                OleDbParameter[] commandParameters =
                    OledbHelperParameterCache.GetSpParameterSet(transaction.Connection.ConnectionString, spName);

                // assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // call the overload that takes an array of OleDbParameters
                return(ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName, commandParameters));
            }

            // otherwise we can just call the SP without params
            return(ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName));
        }