Database Error: duplicate-key violation

Posted By SamC Thu 2 Feb 2017
Add to Favorites0
Author Message
SamC
 Posted Thu 2 Feb 2017
Supreme Being

Supreme Being - (12,857 reputation)Supreme Being - (12,857 reputation)Supreme Being - (12,857 reputation)Supreme Being - (12,857 reputation)Supreme Being - (12,857 reputation)Supreme Being - (12,857 reputation)Supreme Being - (12,857 reputation)Supreme Being - (12,857 reputation)Supreme Being - (12,857 reputation)

Group: Forum Members
Last Active: Mon 9 Sep 2019
Posts: 27, Visits: 117
Hi,

I'm looking for some help with a database related problem which has just started happening for no obvious reason that I can see.

It centres around the 'Product Promotions', and only on some of the items on discount, not all of them. The problem occurs if a customer selects more than one of an item that is on discount ( i.e. two or more of the same product ), then when they checkout the site simply loops back to the checkout page rather than progressing to the payment gateway.

I've looked in the error logs and they seem to be indicating a duplicate key violation. I've been running these kind of promotions for years, with no problems, so I'm struggling to see what might have gone wrong?

Any ideas or advice would be most welcome.

This is the error log:

-----------------------------------------------------------------------------
>> OrdersBLL.Add
-----------------------------------------------------------------------------
>> System.Data.SqlClient.SqlException
>> 02/02/2017 11:49:49
>> Version:2.7001
>> CUSTOM MESSAGE:
Database Error: duplicate-key violation.
>> NUMBER:2627
>> MESSAGE:
Violation of PRIMARY KEY constraint 'PK_tblKartrisOrdersPromotions'. Cannot insert duplicate key in object 'dbo.tblKartrisOrdersPromotions'. The duplicate key value is (33634, 118).
The statement has been terminated.
>> STACK:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at OrdersBLL.Add(Int32 C_ID, String strUserEmailAddress, String strUserPassword, Address BillingAddress, Address ShippingAddress, Boolean blnSameShippingAsBilling, BasketBLL BasketObject, ArrayList BasketArray, String strOrderDetails, String strGatewayName, Int32 intLanguageID, Int32 intCurrencyID, Int32 intGatewayCurrencyID, Boolean blnOrderEmails, String strShippingMethod, Double numGatewayTotalPrice, String strEUVATNumber, String strPromotionDescription, String strPurchaseOrderNo, String strComments)
==================================================

Threaded View

Expand / Collapse
Threaded View
Forum Post Database Error: duplicate-key violation By SamC ( Thu 2 Feb 2017 )
   Forum Post That's great Paul, thanks a lot for your help with this. By SamC ( Tue 14 Mar 2017 )
   Forum Post As you can see, when I add two versions of a product, and I put... By Tiggywiggler ( Thu 9 Feb 2017 )
       Forum Post The image above is the test promotion that I created. I think that... By SamC ( Fri 10 Feb 2017 )
         Forum Post Thank you for this mate. I understand the problem more fully, but it... By Tiggywiggler ( Tue 14 Feb 2017 )
           Forum Post Okay, thanks for that. I'll perhaps try and contact the Kartris team... By SamC ( Mon 20 Feb 2017 )
   Forum Post So the primary key on that table is OrderID, PromotionID which means... By Tiggywiggler ( Thu 2 Feb 2017 )
       Forum Post Thanks for that, much appreciated. I'm struggling to see a pattern as... By SamC ( Fri 3 Feb 2017 )
         Forum Post I see that you are getting it on some products and not some, and that... By Tiggywiggler ( Fri 3 Feb 2017 )
           Forum Post I've been looking at this issue with the promotions a bit more to try... By SamC ( Fri 3 Feb 2017 )
             Forum Post If you CAN reproduce the fault on that version, can you also run up a... By Tiggywiggler ( Sat 4 Feb 2017 )
               Forum Post Okay so I've managed to replicate the problem on a clean install of... By SamC ( Mon 6 Feb 2017 )
                 Forum Post Oh and by the way the error log recorded exactly the same error... By SamC ( Mon 6 Feb 2017 )
                   Forum Post I've just run the same test on the latest version of Kartris ( just... By SamC ( Wed 8 Feb 2017 )
                     Forum Post I am using the latest DEV code we have and I could not replicate the... By Paul ( Fri 10 Mar 2017 )
                     Forum Post Thank you for doing the diagnostics on this one Sam, it looks like... By Tiggywiggler ( Thu 9 Feb 2017 )
                       Forum Post No problem, its good in someways to know that its not something that's... By SamC ( Thu 9 Feb 2017 )
         Forum Post I see that you are getting it on some products and not some, and that... By Tiggywiggler ( Fri 3 Feb 2017 )

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top