FetchDataRow() public méthode

public FetchDataRow ( int statementId, int columns ) : bool
statementId int
columns int
Résultat bool
        private bool GetNextRow()
        {
            bool fetched = driver.FetchDataRow(statementId, Size);

            if (fetched)
            {
                totalRows++;
            }
            return(fetched);
        }
Exemple #2
0
        /// <summary>
        /// Advances the data reader to the next result, when reading the results of batch SQL statements.
        /// </summary>
        /// <returns></returns>
        public override bool NextResult()
        {
            if (!isOpen)
            {
                throw new MySqlException(Resources.NextResultIsClosed);
            }

            bool firstResult = fields == null;

            if (fields != null)
            {
                ClearCurrentResultset();
                fields = null;
            }

            // single result means we only return a single resultset.  If we have already
            // returned one, then we return false;
            if (!firstResult && (commandBehavior & CommandBehavior.SingleResult) != 0)
            {
                return(false);
            }

            // tell our command to continue execution of the SQL batch until it its
            // another resultset
            try
            {
                long fieldCount = GetResultSet();
                if (fieldCount == -1)
                {
                    nextResultDone = true;
                    hasRows        = canRead = false;
                    return(false);
                }

                // issue any requested UA warnings
                if (connection.Settings.UseUsageAdvisor)
                {
                    if ((connection.driver.ServerStatus & ServerStatusFlags.NoIndex) != 0)
                    {
                        connection.UsageAdvisor.UsingNoIndex(command.CommandText);
                    }
                    if ((connection.driver.ServerStatus & ServerStatusFlags.BadIndex) != 0)
                    {
                        connection.UsageAdvisor.UsingBadIndex(command.CommandText);
                    }
                }

                fields = driver.ReadColumnMetadata((int)fieldCount);
                fieldHashCS.Clear();
                fieldHashCI.Clear();
                values = new IMySqlValue[fields.Length];
                for (int i = 0; i < fields.Length; i++)
                {
                    string columnName = fields[i].ColumnName;
                    if (!fieldHashCS.ContainsKey(columnName))
                    {
                        fieldHashCS.Add(columnName, i);
                    }
                    if (!fieldHashCI.ContainsKey(columnName))
                    {
                        fieldHashCI.Add(columnName, i);
                    }
                    values[i] = fields[i].GetValueObject();
                }
                hasRead = false;

                uaFieldsUsed = new bool[fields.Length];
                hasRows      = canRead = driver.FetchDataRow(statement.StatementId, 0, fields.Length);
                return(true);
            }
            catch (MySqlException ex)
            {
                if (ex.IsFatal)
                {
                    connection.Abort();
                }
                nextResultDone = true;
                hasRows        = canRead = false;
                if (command.TimedOut)
                {
                    throw new MySqlException(Resources.Timeout);
                }
                if (ex.Number == 0)
                {
                    throw new MySqlException(Resources.FatalErrorReadingResult, ex);
                }
                throw;
            }
        }