TransactionScope on Oracle

Topics: Data Access Application Block
Mar 26, 2009 at 12:37 PM
Hi,
I have a problem using TransactionScope with DAAB and Oracle, without DAAB all it works OK.

The error I get with DAAB is the following :
ORA-00161: transaction branch length 101 is illegal (maximum allowed 64)

Without DAAB all it works fine. The difference I found is that the DAAB use the DbCommand object, I made the same things with OracleCommand and it works fine.

Debugging I check that the error is on rows 1148 of Database.cs class (connection.Open();).

I use Vista Enterprise on client and  a Win2003 with Oracle 9i installed on db side. I know that there are some issues with Oracle 9i and Vista but I want to discover why with OracleClient library all it works fine.

These are the code I use for test :

//Go in error
        public int DALUpdateUser()
        {
            Database _db = DatabaseFactory.CreateDatabase();
            int ret = 0;
            string _SQL = "UPDATE UA1 SET U10U = U10U WHERE KKK = 1";
            DbCommand cmd = _db.GetSqlStringCommand(_SQL);
            _SQL = "UPDATE UA1 SET U10P = U10P WHERE KKK = 1";
            DbCommand cmd2 = _db.GetSqlStringCommand(_SQL);
            using (TransactionScope ts = new TransactionScope() )
            {
                ret = _db.ExecuteNonQuery(cmd);
                ret += _db.ExecuteNonQuery(cmd2);
            }
            return ret;
        }
//OK
        public int MSUpdateUser()
        {
   
            string _connectionString = "Data Source=DB;User ID=user;Password=xxxx;Unicode=False";
            OracleConnection _conn = new OracleConnection(_connectionString);

            int ret = 0;
            string _SQL = "UPDATE UA1 SET U10U = U10U WHERE KKK = 1";
            OracleCommand cmd = new OracleCommand(_SQL);
            _SQL = "UPDATE UA1 SET U10P = U10P WHERE KKK = 1";
            OracleCommand cmd2 = new OracleCommand(_SQL);
            _conn.Open();
            cmd.Connection = _conn;
            cmd2.Connection = _conn;
            using (TransactionScope ts = new TransactionScope())
            {
                ret = cmd.ExecuteNonQuery();
                ret += cmd2.ExecuteNonQuery();
            }
            _conn.Close();
            return ret;
        }
Mar 27, 2009 at 1:20 PM

Hi,

Maybe this was an issue with Oracle. I have found some links that they might be related. I haven’t tested your code, so these are just assumptions. J

http://social.msdn.microsoft.com/forums/en-US/windowstransactionsprogramming/thread/c015d4ce-0307-46ee-b6f4-e0cf2e0faadf/
Mar 27, 2009 at 1:49 PM
Thanks for the reply,
I checked the link and I understand that there is compatibility problem with Vista and Oracle 9i, now I'm downloading Oracle 11g (certified for Vista) and I will try with this new version.

What I can't understand is why with System.Data.OracleClient namespace I don't get the same problem.

Thanks for all guess you may suggest me.

Kind regards,
Luca