NextRow() public method

public NextRow ( CommandBehavior behavior ) : bool
behavior CommandBehavior
return bool
Example #1
0
        /// <summary>
        /// Advances the MySqlDataReader to the next record.
        /// </summary>
        /// <returns></returns>
        public override bool Read()
        {
            if (!isOpen)
            {
                throw new MySqlException("Invalid attempt to Read when reader is closed.");
            }
            if (resultSet == null)
            {
                return(false);
            }

            try
            {
                return(resultSet.NextRow(commandBehavior));
            }
            catch (TimeoutException tex)
            {
                connection.HandleTimeoutOrThreadAbort(tex);
                throw;                 // unreached
            }
            catch (MySqlException ex)
            {
                if (ex.IsFatal)
                {
                    connection.Abort();
                }

                if (ex.IsQueryAborted)
                {
                    throw;
                }

                throw new MySqlException("ResourceStrings.FatalErrorDuringRead", ex);
            }
        }
Example #2
0
        private void ProcessOutputParameters()
        {
            // if we are not 5.5 or later or we are not prepared then we are simulating output parameters
            // with user variables and they are also string so we have to work some magic with out
            // column types before we read the data
            if (!driver.SupportsOutputParameters || !Command.IsPrepared)
            {
                AdjustOutputTypes();
            }

            // now read the output parameters data row
            if ((CommandBehavior & CommandBehavior.SchemaOnly) != 0)
            {
                return;
            }
            ResultSet.NextRow(CommandBehavior);

            string prefix = "@" + StoredProcedure.ParameterPrefix;

            for (int i = 0; i < FieldCount; i++)
            {
                string fieldName = GetName(i);
                if (fieldName.StartsWith(prefix))
                {
                    fieldName = fieldName.Remove(0, prefix.Length);
                }
                MySqlParameter parameter = Command.Parameters.GetParameterFlexible(fieldName, true);
                parameter.Value = GetValue(i);
            }
        }
Example #3
0
        /// <summary>
        /// Advances the MySqlDataReader to the next record.
        /// </summary>
        /// <returns></returns>
        public override bool Read()
        {
            if (!_isOpen)
            {
                Throw(new MySqlException("Invalid attempt to Read when reader is closed."));
            }
            if (ResultSet == null)
            {
                return(false);
            }

            try
            {
                return(ResultSet.NextRow(CommandBehavior));
            }
            catch (TimeoutException tex)
            {
                _connection.HandleTimeoutOrThreadAbort(tex);
                throw; // unreached
            }
#if !NETSTANDARD1_3
            catch (ThreadAbortException taex)
            {
                _connection.HandleTimeoutOrThreadAbort(taex);
                throw;
            }
#endif
            catch (MySqlException ex)
            {
                if (ex.IsFatal)
                {
                    _connection.Abort();
                }

                if (ex.IsQueryAborted)
                {
                    throw;
                }

                throw new MySqlException(Resources.FatalErrorDuringRead, ex);
            }
        }