Transaction rollback not working with ODP.NET
705601Jul 24 2009 — edited Jul 27 2009Here is client and server configuration
Oracle.DataAccess - 2.102.2.20
Oracle 10g Client - 10.2.0.3.0
Oralce 10g Server - 10.2.0.4
.NET framework - 2.0
I am trying to implement transaction is my program using TransactionScope of System.Transaction namespace. I am not able to rollback transaction in case of exception. Following is a code sample
//string connString = "Data Source=XXX;User ID=schema_abc;Password=schema_abc;enlist=false";
try
{
TransactionOptions tsOptions = new TransactionOptions();
tsOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
TransactionScope tsScope = new TransactionScope(TransactionScopeOption.Required, tsOptions);
OracleConnection dbConOne = new OracleConnection(connString);
OracleCommand cmdOne = new OracleCommand();
cmdOne.Connection = dbConOne;
cmdOne.CommandText = "Insert into T1 Values ('A')";
dbConOne.Open();
cmdOne.ExecuteNonQuery();
dbConOne.Close();
throw new Exception("abc");
OracleConnection dbConTwo = new OracleConnection(connString);
OracleCommand cmdTwo = new OracleCommand();
cmdTwo.Connection = dbConTwo;
cmdTwo.CommandText = "Insert into T2 Values ('B')";
dbConTwo.Open();
cmdTwo.ExecuteNonQuery();
dbConTwo.Close();
tsScope.Complete();
}
catch (Exception ex)
{
Transaction.Current.Rollback();
}
If I set enlist=true i get ORA-00161: transaction branch length 90 is illegal (maximum allowed 64)
If I set enlist=dynamic i get Invalid value for key 'enlist'. Only setting for enlist works for me is enlist=false but that doesnt solve the transaction rollback problem.
Even i tried same thing with the new patch (p6810189_10204_Win32) but rollback is not at all working for me. Any help would be appreciated!
Thanks