public NextResult ( int statementId ) : |
||
statementId | int | |
Résultat |
/// <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 isCaching = command.CommandType == CommandType.TableDirect && command.EnableCaching && (commandBehavior & CommandBehavior.SequentialAccess) == 0; // this will clear out any unread data if (resultSet != null) { resultSet.Close(); if (isCaching) { TableCache.AddToCache(command.CommandText, resultSet); } } // single result means we only return a single resultset. If we have already // returned one, then we return false // TableDirect is basically a select * from a single table so it will generate // a single result also if (resultSet != null && ((commandBehavior & CommandBehavior.SingleResult) != 0 || isCaching)) { return(false); } // next load up the next resultset if any try { do { resultSet = null; // if we are table caching, then try to retrieve the resultSet from the cache if (isCaching) { resultSet = TableCache.RetrieveFromCache(command.CommandText, command.CacheAge); } if (resultSet == null) { resultSet = driver.NextResult(Statement.StatementId, false); if (resultSet == null) { return(false); } if (resultSet.IsOutputParameters && command.CommandType == CommandType.StoredProcedure) { StoredProcedure sp = statement as StoredProcedure; sp.ProcessOutputParameters(this); resultSet.Close(); if (!sp.ServerProvidingOutputParameters) { return(false); } // if we are using server side output parameters then we will get our ok packet // *after* the output parameters resultset resultSet = driver.NextResult(Statement.StatementId, true); } resultSet.Cached = isCaching; } if (resultSet.Size == 0) { Command.lastInsertedId = resultSet.InsertedId; if (affectedRows == -1) { affectedRows = resultSet.AffectedRows; } else { affectedRows += resultSet.AffectedRows; } } } while (resultSet.Size == 0); return(true); } catch (MySqlException ex) { if (ex.IsFatal) { connection.Abort(); } if (ex.Number == 0) { throw new MySqlException(Resources.FatalErrorReadingResult, ex); } if ((commandBehavior & CommandBehavior.CloseConnection) != 0) { Close(); } throw; } }
/// <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); } // this will clear out any unread data if (resultSet != null) { resultSet.Close(); } // single result means we only return a single resultset. If we have already // returned one, then we return false; if (resultSet != null && (commandBehavior & CommandBehavior.SingleResult) != 0) { return(false); } // next load up the next resultset if any try { do { resultSet = null; resultSet = driver.NextResult(Statement.StatementId); if (resultSet == null) { return(false); } if (resultSet.IsOutputParameters) { return(false); } if (resultSet.Size == 0) { Command.lastInsertedId = resultSet.InsertedId; if (affectedRows == -1) { affectedRows = resultSet.AffectedRows; } else { affectedRows += resultSet.AffectedRows; } } } while (resultSet.Size == 0); return(true); } catch (MySqlException ex) { if (ex.IsFatal) { connection.Abort(); } if (ex.Number == 0) { throw new MySqlException(Resources.FatalErrorReadingResult, ex); } throw; } }