SaveAsPurchaseOrder throwing transaction exception

Vote:
 

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.

Thanks

#91332
Oct 02, 2014 17:00
Vote:
 

Hi

Which is the code you are using?

Regards.

/Q

#91349
Oct 03, 2014 9:01
Vote:
 

nothing special about my code:

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

 

#91398
Edited, Oct 03, 2014 16:54
Vote:
 

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.

Regards.

/Q

#91401
Oct 03, 2014 17:43
Vote:
 

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

SaveAsPurchaseOrder()

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.

#91403
Oct 03, 2014 17:51
Vote:
 

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

/Q

#91404
Oct 03, 2014 18:01
Vote:
 
   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) 
#91405
Oct 03, 2014 18:08
Vote:
 

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 ...).

Regards.

/Q

#91441
Oct 06, 2014 3:58
Vote:
 

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

#91465
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.