none
transactionscope hangs with system.data.oeracleclient RRS feed

  • Question

  • hello

    i'm using the OracleClient library on Oracle 10g, for an asp .net application.
    i need to make an atomic insert in a master table and some child tables.I use a dataset, and a custom insert method i've added to the tableadapter.
    When i wrap the insert method inside a transactionscope object the application hangs. As a test, i've tried to open the connection before the adpater method does it, and i've found the application hangs on it. The application hangs even if i put a single insert inside the transactionscope (i mean not distributed transaction).  Below is a sample code of what i'm doing.
    ....  
    
    using (TransactionScope ts = new TransactionScope())
      {
           try{
                   int res = myadapter.Insert(C_REC, C_CLI, C_MOD, C_STA, C_FON, T_PTC_ENT, T_PTC_USC, C_NUM_ARC,
                            D_CRC, D_RIC, C_LUO_CIR, T_OGG, D_CHI_PRA, C_UTE_GES, D_APE_PRA, F_SLL, C_SOC, C_TRN, C_RET, C_STZ,
                            N_PRG_STR, C_ADS, out c_Pra);
                    
                   myotherAdpater.Insert(something);
    
    
                    ts.Complete();
    
                }
                catch(Exception ex)
                {}
           }
     ....
    Am i doing something wrong ?
    Should i use the Oracle library instead (Oracle.DataAccess 10.2.0.100 )   ?
    Otherwise i might use the adpter.connection.beginTransaction(). But how do i share the same transaction between two or more adapters ? they don't expose a Transaction property : when i run it i get an exception saying the command object hasn't the transaction property initialized (of course, nobody did it) ...
    using (System.Data.OracleClient.OracleTransaction trn = myadpater.Connection.BeginTransaction())
    {
            try{
                int res = myadpater.PraticaInsert(C_REC, C_CLI, C_MOD, C_STA, C_FON, T_PTC_ENT, T_PTC_USC, C_NUM_ARC,
                            D_CRC, D_RIC, C_LUO_CIR, T_OGG, D_CHI_PRA, C_UTE_GES, D_APE_PRA, F_SLL, C_SOC, C_TRN, C_RET, C_STZ,
                            N_PRG_STR, C_ADS, out c_Pra);
             
                    trn.Commit();
                }
                catch(Exception ex)
                {
                    trn.Rollback();
                }
    
    }

    thank you in advance

    Wednesday, October 7, 2009 4:30 PM