SaveAsPurchaseOrder throwing transaction exception


Hi All,

All I am doing is calling the method SaveAsPurchaseOrder then accept changes, i decompiled the code and copy paste it so i can step into it, and i found the exception is thrown on the line:

((MetaStorageBase) purchaseOrder).AcceptChanges();

in my cart i have two line items with different skus, and no payment info, nor address info.

the exception message:

The transaction associated with the current connection has completed but has not been disposed.  
The transaction must be disposed before the connection can be used to execute SQL statements.

some says it is a timeout issue, so i configured my machine.config file to increase the maxtimeout


I am not sure what I should do to make it working.

Please help.


Oct 02, 2014 17:00


Which is the code you are using?



Oct 03, 2014 9:01

nothing special about my code:

var cart = OrderContext.Current.GetCart(request.CartName, userId);
cart.SaveAsPurchaseOrder(); // error occurs here


Edited, Oct 03, 2014 16:54

I don't think you have to call cart.AcceptChanges() here. When you call SaveAsPurchaseOrder(), you're creating an purchase order and saving it. the cart now can be discarded.

The code should be

var order = cart.SaveAsPurchaseOrder();

//work with order from here.



Oct 03, 2014 17:43

thanks for pointing this out. but my error is occurring when i call


do i have set\configure anything in the cart before i can convert it to an order? please exacue my simple qustions, i am new to episerver commerce.

Oct 03, 2014 17:51

Can you post the exact stack trace? The code looks correct though ...


Oct 03, 2014 18:01
   at System.Data.SqlClient.SqlInternalConnectionTds.CheckEnlistedTransactionBinding()   
at System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer, TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel, Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean isDelegateControlRequest)  
 at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)   
at System.Data.SqlClient.SqlInternalTransaction.Rollback()  
 at System.Data.SqlClient.SqlTransaction.Rollback()  
 at Mediachase.Data.Provider.TransactionScope.ThreadStaticTransactionScope.Dispose()   
at Mediachase.Data.Provider.TransactionScope.Dispose(Boolean disposing) 
  at Mediachase.Data.Provider.TransactionScope.Dispose()   at Mediachase.Commerce.Orders.Cart.SaveAsPurchaseOrder()  
 at MyProjectMarketing.Business.ServiceBus.OrdersSystemProcessor.CheckoutCompleteOrder(CheckoutCompleteOrderRequest request) 
Oct 03, 2014 18:08

It looks like the issue is in your database itself, instead of the code.

I would suggest to check the database performance, it looks like the hardware it's running on is being slow (out of memory, out of hard disk, fragment hard disk ...).



Oct 06, 2014 3:58

Ok, I will take a look at that. I appreciate your help Quan.

Oct 06, 2014 18:22
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.