Exemplo n.º 1
0
        /// <summary>
        /// Closes the MySqlDataReader object.
        /// </summary>
        public void Close()
        {
            if (!isOpen)
            {
                return;
            }

            try
            {
                // finish any current command
                if (currentResult != null)
                {
                    currentResult.Consume();
                }

                connection.Reader = null;
                command.Consume();

                if (0 != (commandBehavior & CommandBehavior.CloseConnection))
                {
                    connection.Close();
                }
            }
            catch (MySqlException ex)
            {
                if (ex.IsFatal)
                {
                    connection.Reader = null;
                    connection.Terminate();
                }
                throw;
            }
            finally
            {
                isOpen = false;
            }
        }