Exemple #1
0
        /// <summary>
        /// Internal function to execute the next command in an array of commands
        /// </summary>
        internal CommandResult ExecuteBatch(bool stopAtResultSet)
        {
            Driver driver = connection.InternalConnection.Driver;

            while (arraySql.Count > 0)
            {
                byte[] sql = (byte[])arraySql[0];
                arraySql.RemoveAt(0);

                CommandResult result = driver.Send(DBCmd.QUERY, sql);

                if (result.IsResultSet)
                {
                    if (stopAtResultSet)
                    {
                        return(result);
                    }
                    result.Clear();
                    continue;
                }

                // at this point, we know it is a zero field count
                if (updateCount == -1)
                {
                    updateCount = 0;
                }
                updateCount += result.RowsAffected;
            }
            return(null);
        }
Exemple #2
0
 public bool IsAlive()
 {
     try
     {
         CommandResult result = driver.Send(DBCmd.PING, (byte[])null);
         // we don't care about the result.  The fact that it responded is enough
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemple #3
0
        /// <summary>
        /// Overloaded. Rolls back a transaction from a pending state.
        /// </summary>
        public void Rollback()
        {
            if (_conn == null || _conn.State != ConnectionState.Open)
            {
                throw new InvalidOperationException("Connection must be valid and open to commit transaction");
            }
            if (!_open)
            {
                throw new InvalidOperationException("Transaction has already been rolled back or is not pending");
            }
            Driver d = _conn.InternalConnection.Driver;

            try
            {
                d.Send(DBCmd.QUERY, "ROLLBACK");
                _open = false;
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
        }