Пример #1
0
        internal OdbcTransaction Open_BeginTransaction(System.Data.IsolationLevel isolevel)
        {
            ExecutePermission.Demand();
            this.CheckState("BeginTransaction");
            this.RollbackDeadTransaction();
            if ((this.weakTransaction != null) && this.weakTransaction.IsAlive)
            {
                throw ADP.ParallelTransactionsNotSupported(this);
            }
            switch (isolevel)
            {
            case System.Data.IsolationLevel.Unspecified:
            case System.Data.IsolationLevel.ReadUncommitted:
            case System.Data.IsolationLevel.ReadCommitted:
            case System.Data.IsolationLevel.RepeatableRead:
            case System.Data.IsolationLevel.Serializable:
            case System.Data.IsolationLevel.Snapshot:
            {
                OdbcConnectionHandle connectionHandle = this.ConnectionHandle;
                ODBC32.RetCode       retcode          = connectionHandle.BeginTransaction(ref isolevel);
                if (retcode == ODBC32.RetCode.ERROR)
                {
                    this.HandleError(connectionHandle, retcode);
                }
                OdbcTransaction target = new OdbcTransaction(this, isolevel, connectionHandle);
                this.weakTransaction = new WeakReference(target);
                return(target);
            }

            case System.Data.IsolationLevel.Chaos:
                throw ODBC.NotSupportedIsolationLevel(isolevel);
            }
            throw ADP.InvalidIsolationLevel(isolevel);
        }
Пример #2
0
        internal OdbcTransaction Open_BeginTransaction(IsolationLevel isolevel)
        {
            OdbcConnection.ExecutePermission.Demand();

            CheckState(ADP.BeginTransaction); // MDAC 68323

            RollbackDeadTransaction();

            if ((null != this.weakTransaction) && this.weakTransaction.IsAlive)   // regression from Dispose/Finalize work
            {
                throw ADP.ParallelTransactionsNotSupported(this);
            }

            //Use the default for unspecified.
            switch (isolevel)
            {
            case IsolationLevel.Unspecified:
            case IsolationLevel.ReadUncommitted:
            case IsolationLevel.ReadCommitted:
            case IsolationLevel.RepeatableRead:
            case IsolationLevel.Serializable:
            case IsolationLevel.Snapshot:
                break;

            case IsolationLevel.Chaos:
                throw ODBC.NotSupportedIsolationLevel(isolevel);

            default:
                throw ADP.InvalidIsolationLevel(isolevel);
            }
            ;

            //Start the transaction
            OdbcConnectionHandle connectionHandle = ConnectionHandle;

            ODBC32.RetCode retcode = connectionHandle.BeginTransaction(ref isolevel);
            if (retcode == ODBC32.RetCode.ERROR)
            {
                HandleError(connectionHandle, retcode);
            }
            OdbcTransaction transaction = new OdbcTransaction(this, isolevel, connectionHandle);

            this.weakTransaction = new WeakReference(transaction); // MDAC 69188
            return(transaction);
        }