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); }
internal ODBC32.RetCode BeginTransaction(ref System.Data.IsolationLevel isolevel) { ODBC32.RetCode sUCCESS = ODBC32.RetCode.SUCCESS; if (System.Data.IsolationLevel.Unspecified != isolevel) { ODBC32.SQL_ATTR sql_attr; ODBC32.SQL_TRANSACTION sERIALIZABLE; switch (isolevel) { case System.Data.IsolationLevel.RepeatableRead: sERIALIZABLE = ODBC32.SQL_TRANSACTION.REPEATABLE_READ; sql_attr = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case System.Data.IsolationLevel.Serializable: sERIALIZABLE = ODBC32.SQL_TRANSACTION.SERIALIZABLE; sql_attr = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case System.Data.IsolationLevel.Snapshot: sERIALIZABLE = ODBC32.SQL_TRANSACTION.SNAPSHOT; sql_attr = ODBC32.SQL_ATTR.SQL_COPT_SS_TXN_ISOLATION; break; case System.Data.IsolationLevel.Chaos: throw ODBC.NotSupportedIsolationLevel(isolevel); case System.Data.IsolationLevel.ReadUncommitted: sERIALIZABLE = ODBC32.SQL_TRANSACTION.READ_UNCOMMITTED; sql_attr = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case System.Data.IsolationLevel.ReadCommitted: sERIALIZABLE = ODBC32.SQL_TRANSACTION.READ_COMMITTED; sql_attr = ODBC32.SQL_ATTR.TXN_ISOLATION; break; default: throw ADP.InvalidIsolationLevel(isolevel); } sUCCESS = this.SetConnectionAttribute2(sql_attr, (IntPtr)((long)sERIALIZABLE), -6); if (ODBC32.RetCode.SUCCESS_WITH_INFO == sUCCESS) { isolevel = System.Data.IsolationLevel.Unspecified; } } switch (sUCCESS) { case ODBC32.RetCode.SUCCESS: case ODBC32.RetCode.SUCCESS_WITH_INFO: sUCCESS = this.AutoCommitOff(); this._handleState = HandleState.TransactionInProgress; return(sUCCESS); } return(sUCCESS); }
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); }
internal ODBC32.RetCode BeginTransaction(ref IsolationLevel isolevel) { ODBC32.RetCode retcode = ODBC32.RetCode.SUCCESS; ODBC32.SQL_ATTR isolationAttribute; if (IsolationLevel.Unspecified != isolevel) { ODBC32.SQL_TRANSACTION sql_iso; switch (isolevel) { case IsolationLevel.ReadUncommitted: sql_iso = ODBC32.SQL_TRANSACTION.READ_UNCOMMITTED; isolationAttribute = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case IsolationLevel.ReadCommitted: sql_iso = ODBC32.SQL_TRANSACTION.READ_COMMITTED; isolationAttribute = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case IsolationLevel.RepeatableRead: sql_iso = ODBC32.SQL_TRANSACTION.REPEATABLE_READ; isolationAttribute = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case IsolationLevel.Serializable: sql_iso = ODBC32.SQL_TRANSACTION.SERIALIZABLE; isolationAttribute = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case IsolationLevel.Snapshot: sql_iso = ODBC32.SQL_TRANSACTION.SNAPSHOT; // VSDD 414121: Snapshot isolation level must be set through SQL_COPT_SS_TXN_ISOLATION (http://msdn.microsoft.com/en-us/library/ms131709.aspx) isolationAttribute = ODBC32.SQL_ATTR.SQL_COPT_SS_TXN_ISOLATION; break; case IsolationLevel.Chaos: throw ODBC.NotSupportedIsolationLevel(isolevel); default: throw ADP.InvalidIsolationLevel(isolevel); } //Set the isolation level (unless its unspecified) retcode = SetConnectionAttribute2(isolationAttribute, (IntPtr)sql_iso, (Int32)ODBC32.SQL_IS.INTEGER); //Note: The Driver can return success_with_info to indicate it "rolled" the //isolevel to the next higher value. If this is the case, we need to requery //the value if th euser asks for it... //We also still propagate the info, since it could be other info as well... if (ODBC32.RetCode.SUCCESS_WITH_INFO == retcode) { isolevel = IsolationLevel.Unspecified; } } switch (retcode) { case ODBC32.RetCode.SUCCESS: case ODBC32.RetCode.SUCCESS_WITH_INFO: //Turn off auto-commit (which basically starts the transaction) retcode = AutoCommitOff(); _handleState = HandleState.TransactionInProgress; break; } return(retcode); }