Example #1
0
		new public MySqlTransaction BeginTransaction( System.Data.IsolationLevel iso ) {
			if( this.State != ConnectionState.Open ) {
				throw new InvalidOperationException( Resources.ConnectionNotOpen );
			}
			if( ( this.driver.ServerStatus & ServerStatusFlags.InTransaction ) != 0 ) {
				throw new InvalidOperationException( Resources.NoNestedTransactions );
			}
			MySqlTransaction transaction = new MySqlTransaction( this, iso );
			MySqlCommand command = new MySqlCommand( "", this );
			command.CommandText = "SET SESSION TRANSACTION ISOLATION LEVEL ";
			switch( iso ) {
				case System.Data.IsolationLevel.Chaos:
					throw new NotSupportedException( Resources.ChaosNotSupported );

				case System.Data.IsolationLevel.ReadUncommitted:
					command.CommandText = command.CommandText + "READ UNCOMMITTED";
					goto Label_00F1;

				case System.Data.IsolationLevel.ReadCommitted:
					command.CommandText = command.CommandText + "READ COMMITTED";
					break;

				case System.Data.IsolationLevel.RepeatableRead:
					command.CommandText = command.CommandText + "REPEATABLE READ";
					break;

				case System.Data.IsolationLevel.Serializable:
					command.CommandText = command.CommandText + "SERIALIZABLE";
					break;
			}
Label_00F1:
			command.ExecuteNonQuery();
			command.CommandText = "BEGIN";
			command.ExecuteNonQuery();
			return transaction;
		}
Example #2
0
 private static MySqlDataReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, string commandText, MySqlParameter[] commandParameters, bool ExternalConn)
 {
     MySqlDataReader reader;
     MySqlCommand command = new MySqlCommand();
     command.Connection = connection;
     command.Transaction = transaction;
     command.CommandText = commandText;
     command.CommandType = CommandType.Text;
     if (commandParameters != null)
     {
         foreach (MySqlParameter parameter in commandParameters)
         {
             command.Parameters.Add(parameter);
         }
     }
     if (ExternalConn)
     {
         reader = command.ExecuteReader();
     }
     else
     {
         reader = command.ExecuteReader(CommandBehavior.CloseConnection);
     }
     command.Parameters.Clear();
     return reader;
 }
		void IPromotableSinglePhaseNotification.Initialize() {
			string name = Enum.GetName( typeof( System.Transactions.IsolationLevel ), this.baseTransaction.IsolationLevel );
			System.Data.IsolationLevel iso = (System.Data.IsolationLevel)Enum.Parse( typeof( System.Data.IsolationLevel ), name );
			this.simpleTransaction = this.connection.BeginTransaction( iso );
		}
Example #4
0
		public MySqlCommand( string cmdText, MySqlConnection connection, MySqlTransaction transaction )
			: this( cmdText, connection ) {
			this.curTransaction = transaction;
		}