Exemple #1
0
        // OdbcCommand.Cancel()
        //
        // In ODBC3.0 ... a call to SQLCancel when no processing is done has no effect at all
        // (ODBC Programmer's Reference ...)
        //

        public override void Cancel()
        {
            CMDWrapper wrapper = _cmdWrapper;

            if (null != wrapper)
            {
                wrapper.Canceling = true;
                OdbcStatementHandle stmt = wrapper.StatementHandle;
                if (null != stmt)
                {
                    lock (stmt)
                    {
                        // Cancel the statement
                        ODBC32.RetCode retcode = stmt.Cancel();

                        // copy of StatementErrorHandler, because stmt may become null
                        switch (retcode)
                        {
                        case ODBC32.RetCode.SUCCESS:
                        case ODBC32.RetCode.SUCCESS_WITH_INFO:
                            // don't fire info message events on cancel
                            break;

                        default:
                            throw wrapper.Connection.HandleErrorNoThrow(stmt, retcode);
                        }
                    }
                }
            }
        }
        public override void Cancel()
        {
            CMDWrapper wrapper = this._cmdWrapper;

            if (wrapper != null)
            {
                wrapper.Canceling = true;
                OdbcStatementHandle statementHandle = wrapper.StatementHandle;
                if (statementHandle != null)
                {
                    lock (statementHandle)
                    {
                        ODBC32.RetCode retcode = statementHandle.Cancel();
                        switch (retcode)
                        {
                        case ODBC32.RetCode.SUCCESS:
                        case ODBC32.RetCode.SUCCESS_WITH_INFO:
                            return;
                        }
                        throw wrapper.Connection.HandleErrorNoThrow(statementHandle, retcode);
                    }
                }
            }
        }