Problem with transactionsProblem with transactions
Old forum URL: forums.lhotka.net/forums/t/3318.aspx
Viktor posted on Friday, August 03, 2007
I have a problem using transactions. I use transaction when saving the BO «Order», that changes other BOs. I use DataPortal_Execute with attribute: « [Transactional(TransactionalTypes.TransactionScope)]» for transaction. When I get one of the BOs from the database to change this BO, sometimes I receive a SQL Exception:
Transaction context in use by another session
I found, it happens when system tries to check validation rule of the getting BO. The BO applies to the stored procedure using DataPortal_Execute in this rule.
I have no transactions in SQL stored procedures.
How can I correct this error?triplea replied on Friday, August 03, 2007
Just out of curiostiy, why do you change another BO (if I understand well) by fetching and modifying it from within your <<Order>> DataPortal_Execute? I can imagine that will prolong your original transaction in the first place. Maybe you would like to review and move this functionality within you Save() method.
Anyhow, the problem probably lies in the fact you fetch a BO after you started your transaction within your DataPortal_Execute with another seperate connection (again if I understand well). To prove if that is the case, try fetching your other BO using the same attribute [Transactional(TransactionalTypes.TransactionScope)].
Also are you using SQL Server 2000 or 2005?
Viktor replied on Friday, August 03, 2007
Thanks a lot, I’ll try it but in fact I used fetch in transaction some times and it works fine. I used «[Transactional(TransactionalTypes.TransactionScope)]» in other BOs and that error appeared again.
I’m using SQL 2005
Copyright (c) Marimer LLC