Error with promotions v2.5


https://forum.kartris.com/Topic2617.aspx
Print Topic | Close Window

By TheCalicoTree - Thu 28 Nov 2013
We recently upgraded to 2.5 to get around some earlier errors (particularly with promotions). Now, when a customer tries to buy a promotional offer it gets to the checkout Proceed button and then errors...
[code]

----------------------------------------------------------------------------

>> OrdersBLL.Add

-----------------------------------------------------------------------------

>> System.Data.SqlClient.SqlException

>> 24/11/201318:28:14

>> Version:2.5005

>> URL:http://www.hotel-buyer-store.co.uk/Checkout.aspx

>> 109.204.115.163

>> CUSTOMMESSAGE:

Database Error: duplicate-key violation.

>> NUMBER:2627

>> MESSAGE:

Violation of PRIMARY KEY constraint'PK_tblKartrisOrdersPromotions'. Cannot insert duplicate key in object'dbo.tblKartrisOrdersPromotions'.

The statement has been terminated.

>> STACK:

atSystem.Data.SqlClient.SqlConnection.OnError(SqlException exception, BooleanbreakConnection)

atSystem.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception,Boolean breakConnection)

atSystem.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()

atSystem.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler,SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj)

atSystem.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior, String resetOptionsString)

at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehaviorcmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)

atSystem.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResultresult)

atSystem.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result,String methodName, Boolean sendToPipe)

atSystem.Data.SqlClient.SqlCommand.ExecuteNonQuery()

atOrdersBLL.Add(Int32 C_ID, String strUserEmailAddress, String strUserPassword,Address BillingAddress, Address ShippingAddress, BooleanblnSameShippingAsBilling, BasketBLL BasketObject, ArrayList BasketArray, StringstrOrderDetails, String strGatewayName, Int32 intLanguageID, Int32intCurrencyID, Int32 intGatewayCurrencyID, Boolean blnOrderEmails, StringstrShippingMethod, Double numGatewayTotalPrice, String strEUVATNumber, StringstrPromotionDescription, String strPurchaseOrderNo, String strComments)

==================================================

[/code]

Having looked at tblKartrisOrdersPromotions I can see that there is no data so I do not understand how it can be erroring on a duplicate key.
By Paul - Thu 28 Nov 2013
Curious... I tested a 2.5008 locally and it works ok, so I can only think is related to something not upgrading right.

The tblKartrisOrdersPromotions table has two columns, one for the promotion ID, another for the order ID. The combination of these is enforced as a unique key.

The only way I can think a duplicate key issue would happen is if for some reason, it is inserting the same thing twice... that might trigger the error and then a rollback of the transaction, so nothing remains in the db (transactions are bundled operations that either succeed or fail as a whole - if there is a failure in some part, the whole thing is rolled back). But I am not exactly sure how that can happen as I can't reproduce the same thing).
By TheCalicoTree - Thu 28 Nov 2013
Thanks Paul - we're 2.5005 not 8 so I'm not sure if you can test with that?

The error occurred 10 times in rapid succession during that one transaction. Worryingly it also incremented the order numbers by 10 although no orders were actually created.

We used the data tool to upgrade our database as I was unable to get the upgrade scripts running.

tblKartrisOrdersPromotions is empty so I cannot see how a duplicate key error would occur unless it was trying to write a null record? But then that would fail on NULL values I think.