Ejemplo n.º 1
0
        public OleDbTransaction Begin(IsolationLevel isolevel)
        {
            if (null == _transaction)
            {
                throw ADP.TransactionZombied(this);
            }
            else if ((null != _nestedTransaction) && _nestedTransaction.IsAlive)
            {
                throw ADP.ParallelTransactionsNotSupported(Connection !);
            }
            // either the connection will be open or this will be a zombie

            OleDbTransaction transaction = new OleDbTransaction(_parentConnection, this, isolevel);

            _nestedTransaction = new WeakReference(transaction, false);

            UnsafeNativeMethods.ITransactionLocal?wrapper = null;
            try
            {
                wrapper = (UnsafeNativeMethods.ITransactionLocal)_transaction.ComWrapper();
                transaction.BeginInternal(wrapper);
            }
            finally
            {
                if (null != wrapper)
                {
                    Marshal.ReleaseComObject(wrapper);
                }
            }
            return(transaction);
        }
Ejemplo n.º 2
0
        public override DbTransaction BeginTransaction(IsolationLevel isolationLevel)
        {
            OleDbConnection outerConnection = Connection;

            if (null != LocalTransaction)
            {
                throw ADP.ParallelTransactionsNotSupported(outerConnection);
            }

            object           unknown = null;
            OleDbTransaction transaction;

            try
            {
                transaction = new OleDbTransaction(outerConnection, null, isolationLevel);
                Debug.Assert(null != _datasrcwrp, "ITransactionLocal: null datasource");
                Debug.Assert(null != _sessionwrp, "ITransactionLocal: null session");
                unknown = _sessionwrp.ComWrapper();
                UnsafeNativeMethods.ITransactionLocal value = (unknown as UnsafeNativeMethods.ITransactionLocal);
                if (null == value)
                {
                    throw ODB.TransactionsNotSupported(Provider, (Exception)null);
                }
                transaction.BeginInternal(value);
            }
            finally
            {
                if (null != unknown)
                {
                    Marshal.ReleaseComObject(unknown);
                }
            }
            LocalTransaction = transaction;
            return(transaction);
        }
        public override DbTransaction BeginTransaction(System.Data.IsolationLevel isolationLevel)
        {
            OleDbTransaction transaction;

            OleDbConnection.ExecutePermission.Demand();
            OleDbConnection connection = this.Connection;

            if (this.LocalTransaction != null)
            {
                throw ADP.ParallelTransactionsNotSupported(connection);
            }
            object o = null;

            try
            {
                transaction = new OleDbTransaction(connection, null, isolationLevel);
                Bid.Trace("<oledb.IUnknown.QueryInterface|API|OLEDB|session> %d#, ITransactionLocal\n", base.ObjectID);
                o = this._sessionwrp.ComWrapper();
                System.Data.Common.UnsafeNativeMethods.ITransactionLocal local = o as System.Data.Common.UnsafeNativeMethods.ITransactionLocal;
                if (local == null)
                {
                    throw ODB.TransactionsNotSupported(this.Provider, null);
                }
                transaction.BeginInternal(local);
            }
            finally
            {
                if (o != null)
                {
                    Marshal.ReleaseComObject(o);
                }
            }
            this.LocalTransaction = transaction;
            return(transaction);
        }
Ejemplo n.º 4
0
        /// <include file='doc\OleDbTransaction.uex' path='docs/doc[@for="OleDbTransaction.Begin"]/*' />
        public OleDbTransaction Begin(IsolationLevel isolevel)
        {
            OleDbConnection.OleDbPermission.Demand(); // MDAC 81476

            if (null == this.localTransaction)
            {
                throw ADP.TransactionZombied(this);
            }
            parentConnection.CheckStateOpen(ADP.BeginTransaction);
            OleDbTransaction transaction = new OleDbTransaction(this.parentConnection);

            this.weakTransaction = new WeakReference(transaction);
            transaction.BeginInternal(this.localTransaction, isolevel);
            transaction.parentTransaction = this;
            return(transaction);
        }
Ejemplo n.º 5
0
        public OleDbTransaction Begin(System.Data.IsolationLevel isolevel)
        {
            OleDbTransaction transaction2;
            IntPtr           ptr;

            OleDbConnection.ExecutePermission.Demand();
            Bid.ScopeEnter(out ptr, "<oledb.OleDbTransaction.Begin|API> %d#, isolevel=%d{IsolationLevel}", this.ObjectID, (int)isolevel);
            try
            {
                if (this._transaction == null)
                {
                    throw ADP.TransactionZombied(this);
                }
                if ((this._nestedTransaction != null) && this._nestedTransaction.IsAlive)
                {
                    throw ADP.ParallelTransactionsNotSupported(this.Connection);
                }
                OleDbTransaction target = new OleDbTransaction(this._parentConnection, this, isolevel);
                this._nestedTransaction = new WeakReference(target, false);
                UnsafeNativeMethods.ITransactionLocal transaction = null;
                try
                {
                    transaction = (UnsafeNativeMethods.ITransactionLocal) this._transaction.ComWrapper();
                    target.BeginInternal(transaction);
                }
                finally
                {
                    if (transaction != null)
                    {
                        Marshal.ReleaseComObject(transaction);
                    }
                }
                transaction2 = target;
            }
            finally
            {
                Bid.ScopeLeave(ref ptr);
            }
            return(transaction2);
        }
 public OleDbTransaction Begin(System.Data.IsolationLevel isolevel)
 {
     OleDbTransaction transaction2;
     IntPtr ptr;
     OleDbConnection.ExecutePermission.Demand();
     Bid.ScopeEnter(out ptr, "<oledb.OleDbTransaction.Begin|API> %d#, isolevel=%d{IsolationLevel}", this.ObjectID, (int) isolevel);
     try
     {
         if (this._transaction == null)
         {
             throw ADP.TransactionZombied(this);
         }
         if ((this._nestedTransaction != null) && this._nestedTransaction.IsAlive)
         {
             throw ADP.ParallelTransactionsNotSupported(this.Connection);
         }
         OleDbTransaction target = new OleDbTransaction(this._parentConnection, this, isolevel);
         this._nestedTransaction = new WeakReference(target, false);
         UnsafeNativeMethods.ITransactionLocal transaction = null;
         try
         {
             transaction = (UnsafeNativeMethods.ITransactionLocal) this._transaction.ComWrapper();
             target.BeginInternal(transaction);
         }
         finally
         {
             if (transaction != null)
             {
                 Marshal.ReleaseComObject(transaction);
             }
         }
         transaction2 = target;
     }
     finally
     {
         Bid.ScopeLeave(ref ptr);
     }
     return transaction2;
 }
Ejemplo n.º 7
0
        public OleDbTransaction Begin(IsolationLevel isolevel)
        {
            OleDbConnection.ExecutePermission.Demand(); // MDAC 81476

            IntPtr hscp;

            Bid.ScopeEnter(out hscp, "<oledb.OleDbTransaction.Begin|API> %d#, isolevel=%d{IsolationLevel}", ObjectID, (int)isolevel);
            try {
                if (null == _transaction)
                {
                    throw ADP.TransactionZombied(this);
                }
                else if ((null != _nestedTransaction) && _nestedTransaction.IsAlive)
                {
                    throw ADP.ParallelTransactionsNotSupported(Connection);
                }
                // either the connection will be open or this will be a zombie

                OleDbTransaction transaction = new OleDbTransaction(_parentConnection, this, isolevel);
                _nestedTransaction = new WeakReference(transaction, false);

                UnsafeNativeMethods.ITransactionLocal wrapper = null;
                try {
                    wrapper = (UnsafeNativeMethods.ITransactionLocal)_transaction.ComWrapper();
                    transaction.BeginInternal(wrapper);
                }
                finally {
                    if (null != wrapper)
                    {
                        Marshal.ReleaseComObject(wrapper);
                    }
                }
                return(transaction);
            }
            finally {
                Bid.ScopeLeave(ref hscp);
            }
        }
        public OleDbTransaction Begin(IsolationLevel isolevel) {
            OleDbConnection.ExecutePermission.Demand(); // MDAC 81476

            IntPtr hscp;
            Bid.ScopeEnter(out hscp, "<oledb.OleDbTransaction.Begin|API> %d#, isolevel=%d{IsolationLevel}", ObjectID, (int)isolevel);
            try {
                if (null == _transaction) {
                    throw ADP.TransactionZombied(this);
                }
                else if ((null != _nestedTransaction) && _nestedTransaction.IsAlive) {
                    throw ADP.ParallelTransactionsNotSupported(Connection);
                }
                // either the connection will be open or this will be a zombie

                OleDbTransaction transaction = new OleDbTransaction(_parentConnection, this, isolevel);
                _nestedTransaction = new WeakReference(transaction, false);

                UnsafeNativeMethods.ITransactionLocal wrapper = null;
                try {
                    wrapper = (UnsafeNativeMethods.ITransactionLocal)_transaction.ComWrapper();
                    transaction.BeginInternal(wrapper);
                }
                finally {
                    if (null != wrapper) {
                        Marshal.ReleaseComObject(wrapper);
                    }
                }
                return transaction;
            }
            finally {
                Bid.ScopeLeave(ref hscp);
            }
        }
        override public DbTransaction BeginTransaction(IsolationLevel isolationLevel) {
            OleDbConnection.ExecutePermission.Demand();

            OleDbConnection outerConnection = Connection;
            if (null != LocalTransaction) {
                throw ADP.ParallelTransactionsNotSupported(outerConnection);
            }

            object unknown = null;
            OleDbTransaction transaction;
            try {
                transaction = new OleDbTransaction(outerConnection, null, isolationLevel);

                Bid.Trace("<oledb.IUnknown.QueryInterface|API|OLEDB|session> %d#, ITransactionLocal\n", ObjectID);
                Debug.Assert(null != _datasrcwrp, "ITransactionLocal: null datasource");
                Debug.Assert(null != _sessionwrp, "ITransactionLocal: null session");
                unknown = _sessionwrp.ComWrapper();
                UnsafeNativeMethods.ITransactionLocal value = (unknown as UnsafeNativeMethods.ITransactionLocal);
                if (null == value) {
                    throw ODB.TransactionsNotSupported(Provider, (Exception)null);
                }
                transaction.BeginInternal(value);
            }
            finally {
                if (null != unknown) {
                    Marshal.ReleaseComObject(unknown);
                }
            }
            LocalTransaction = transaction;
            return transaction;
        }