public ReadColumnValue ( int index, |
||
index | int | |
field | ||
value | IMySqlValue | |
return | IMySqlValue |
/// <summary> /// Retrieve the value as the given column index /// </summary> /// <param name="index">The column value to retrieve</param> /// <returns>The value as the given column</returns> public IMySqlValue this[int index] { get { if (rowIndex < 0) { throw new MySqlException(Resources.AttemptToAccessBeforeRead); } // keep count of how many columns we have left to access uaFieldsUsed[index] = true; if (isSequential && index != seqIndex) { if (index < seqIndex) { throw new MySqlException(Resources.ReadingPriorColumnUsingSeqAccess); } while (seqIndex < (index - 1)) { driver.SkipColumnValue(values[++seqIndex]); } values[index] = driver.ReadColumnValue(index, fields[index], values[index]); seqIndex = index; } return(values[index]); } }
/// <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 (!canRead) { return(false); } if (Behavior == CommandBehavior.SingleRow && hasRead) { return(false); } try { bool isSequential = (Behavior & CommandBehavior.SequentialAccess) != 0; seqIndex = -1; if (hasRead) { canRead = driver.FetchDataRow(statement.StatementId, 0, fields.Length); } hasRead = true; if (canRead && !isSequential) { for (int i = 0; i < fields.Length; i++) { values[i] = driver.ReadColumnValue(i, fields[i], values[i]); } } return(canRead); } catch (MySqlException ex) { if (ex.IsFatal) { connection.Abort(); } // if we get a query interrupted then our resultset is done if (ex.Number == 1317) { nextResultDone = true; canRead = false; if (command.TimedOut) { throw new MySqlException(Resources.Timeout); } return(false); } throw new MySqlException(Resources.FatalErrorDuringRead, ex); } }
/// <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 (!canRead) { return(false); } if (Behavior == CommandBehavior.SingleRow && hasRead) { return(false); } try { bool isSequential = (Behavior & CommandBehavior.SequentialAccess) != 0; seqIndex = -1; if (hasRead) { canRead = driver.FetchDataRow(statement.StatementId, 0, fields.Length); } hasRead = true; if (canRead && !isSequential) { for (int i = 0; i < fields.Length; i++) { values[i] = driver.ReadColumnValue(i, fields[i], values[i]); } } return(canRead); } catch (MySqlException ex) { if (ex.IsFatal) { connection.Abort(); } throw; } }