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);
        }