Example #1
0
        // dbindings handle can't be freed until the output parameters
        // have been filled in which occurs after the last rowset is released
        // dbbindings.FreeDataHandle occurs in Cloe
        private int ExecuteCommandText(out object executeResult)
        {
            int         retcode;
            tagDBPARAMS dbParams    = null;
            RowBinding  rowbinding  = null;
            Bindings    bindings    = ParameterBindings;
            bool        mustRelease = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                if (null != bindings)
                { // parameters may be suppressed
                    rowbinding = bindings.RowBinding();

                    rowbinding.DangerousAddRef(ref mustRelease);

                    // bindings can't be released until after last rowset is released
                    // that is when output parameters are populated
                    // initialize the input parameters to the input databuffer
                    bindings.ApplyInputParameters();

                    dbParams            = new tagDBPARAMS();
                    dbParams.pData      = rowbinding.DangerousGetDataPtr();
                    dbParams.cParamSets = 1;
                    dbParams.hAccessor  = rowbinding.DangerousGetAccessorHandle();
                }
                if ((0 == (CommandBehavior.SingleResult & this.commandBehavior)) && _connection.SupportMultipleResults())
                {
                    retcode = ExecuteCommandTextForMultpleResults(dbParams, out executeResult);
                }
                else if (0 == (CommandBehavior.SingleRow & this.commandBehavior) || !_executeQuery)
                {
                    retcode = ExecuteCommandTextForSingleResult(dbParams, out executeResult);
                }
                else
                {
                    retcode = ExecuteCommandTextForSingleRow(dbParams, out executeResult);
                }
            }
            finally
            {
                if (mustRelease)
                {
                    rowbinding.DangerousRelease();
                }
            }
            return(retcode);
        }
        private int ExecuteCommandText(out object executeResult)
        {
            tagDBPARAMS dbParams = null;
            RowBinding  binding  = null;
            int         num;
            Bindings    parameterBindings = this.ParameterBindings;
            bool        success           = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                if (parameterBindings != null)
                {
                    binding = parameterBindings.RowBinding();
                    binding.DangerousAddRef(ref success);
                    parameterBindings.ApplyInputParameters();
                    dbParams = new tagDBPARAMS {
                        pData      = binding.DangerousGetDataPtr(),
                        cParamSets = 1,
                        hAccessor  = binding.DangerousGetAccessorHandle()
                    };
                }
                if (((CommandBehavior.SingleResult & this.commandBehavior) == CommandBehavior.Default) && this._connection.SupportMultipleResults())
                {
                    return(this.ExecuteCommandTextForMultpleResults(dbParams, out executeResult));
                }
                if (((CommandBehavior.SingleRow & this.commandBehavior) == CommandBehavior.Default) || !this._executeQuery)
                {
                    return(this.ExecuteCommandTextForSingleResult(dbParams, out executeResult));
                }
                num = this.ExecuteCommandTextForSingleRow(dbParams, out executeResult);
            }
            finally
            {
                if (success)
                {
                    binding.DangerousRelease();
                }
            }
            return(num);
        }