Пример #1
0
        // -------------------------------------------------------------------------------
        // ExecuteReader
        // -------------------------------------------------------------------------------
        MySQLRowsReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, string sql, params MySqlParameter[] args)
        {
            bool createLocalConnection = false;

            if (connection == null)
            {
                connection  = NewConnection();
                transaction = null;
                connection.Open();
                createLocalConnection = true;
            }
            MySQLRowsReader result = new MySQLRowsReader();

            using (MySqlCommand cmd = new MySqlCommand(sql, connection))
            {
                if (transaction != null)
                {
                    cmd.Transaction = transaction;
                }
                foreach (MySqlParameter arg in args)
                {
                    cmd.Parameters.Add(arg);
                }
                MySqlDataReader dataReader = cmd.ExecuteReader();
                result.Init(dataReader);
                dataReader.Close();
            }
            if (createLocalConnection)
            {
                connection.Close();
            }
            return(result);
        }
Пример #2
0
        // -------------------------------------------------------------------------------
        // ExecuteReader
        // -------------------------------------------------------------------------------
        MySQLRowsReader ExecuteReader(string sql, params MySqlParameter[] args)
        {
            MySqlConnection connection = NewConnection();

            connection.Open();
            MySQLRowsReader result = ExecuteReader(connection, null, sql, args);

            connection.Close();
            return(result);
        }