Database Error: duplicate-key violation

Posted By SamC Thu 2 Feb 2017
Add to Favorites0
Author Message
SamC
 Posted Tue 14 Mar 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
That's great Paul, thanks a lot for your help with this.
Paul Marked As Answer
 Posted Fri 10 Mar 2017
große Käse

große Käse - (522,212 reputation)große Käse - (522,212 reputation)große Käse - (522,212 reputation)große Käse - (522,212 reputation)große Käse - (522,212 reputation)große Käse - (522,212 reputation)große Käse - (522,212 reputation)große Käse - (522,212 reputation)große Käse - (522,212 reputation)

Group: Administrators
Last Active: Tue 10 Sep 2024
Posts: 807, Visits: 2,748
I am using the latest DEV code we have and I could not replicate the issue. I placed three different versions of the same product into the basket, and all three triggered the same promotion (so effectively that promotion x3). I checked out fine and when I check the tblKartrisOrderPromotions table, only one record was added to log the promotion for that order.

I am going to zip up a new build of Kartris; we've had a lot of minor tweaks and changes over last few months. I will send you a link, can you see if you install that whether you get the issue.

In the meantime, looking at the code (this is for your version before the basket refactoring), maybe the following might fix the issue without upgrading or installing a new version. In /App_Code/BLL/OrdersBLL.vb. Find this code around line 700 or so:

If objBasket.PromotionDiscount.IncTax < 0 Then
Dim objPromotions As New ArrayList
Dim objPromotionsDiscount As New ArrayList
objBasket.CalculatePromotions(objPromotions, objPromotionsDiscount, False)
For Each objPromotion As PromotionBasketModifier In objPromotionsDiscount
Dim cmdAddPromotionLinks As New SqlCommand("spKartrisOrdersPromotions_Add", sqlConn, savePoint)
With cmdAddPromotionLinks
.CommandType = CommandType.StoredProcedure
.Parameters.AddWithValue("@OrderID", O_ID)
.Parameters.AddWithValue("@PromotionID", objPromotion.PromotionID)
.ExecuteNonQuery()
End With
Next
End If


Then add a try/catch in there, so if the subsequent record additions fail, it won't fail the whole order, but hopefully just skip adding those extra record:

If objBasket.PromotionDiscount.IncTax < 0 Then
Dim objPromotions As New ArrayList
Dim objPromotionsDiscount As New ArrayList
objBasket.CalculatePromotions(objPromotions, objPromotionsDiscount, False)
For Each objPromotion As PromotionBasketModifier In objPromotionsDiscount

Try
Dim cmdAddPromotionLinks As New SqlCommand("spKartrisOrdersPromotions_Add", sqlConn, savePoint)
With cmdAddPromotionLinks
.CommandType = CommandType.StoredProcedure
.Parameters.AddWithValue("@OrderID", O_ID)
.Parameters.AddWithValue("@PromotionID", objPromotion.PromotionID)
.ExecuteNonQuery()
End With
Catch ex As Exception
'skip
End Try

Next
End If



--
If my post solves your issue, can you 'Mark as Answer' so it's easier for other users to find in future.

If you would like to be informed of new features, new releases, developments and occasional special bonuses, please sign up to our mailing list: http://bit.ly/19sKMZb
Fri 10 Mar 2017 by Paul
SamC
 Posted Mon 20 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
Okay, thanks for that. I'll perhaps try and contact the Kartris team and see how I go with that. Thanks for you help and advice with this.
Tiggywiggler
 Posted Tue 14 Feb 2017
Supreme Being

Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)

Group: Forum Members
Last Active: Mon 6 Dec 2021
Posts: 235, Visits: 750
Thank you for this mate. I understand the problem more fully, but it is going to require more time than I have free at the moment. I think your only option is to either fix it yourself, try to get a quote from one of the development partners (there is a link in the signature of all of my posts) or speak to the Kartris team to get it expedited.

If none of these are real options to you it will simply be a matter of being very patient and waiting until another coder on the forum has some spare time to help out.


We are always willing to help out the community or pitch in to help you fix a problem. However, if you want a complete solution made such as a code module or new feature added you have two options. Either
1) Reach out to the Kartris internal development team at http://www.kartris.com/Contact.aspx.
2) Contact one of the Kartris approved partners at http://www.kartris.com/t-Worldwide-Developers.aspx.

Have fun and good luck coding.
SamC
 Posted Fri 10 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
http://forum.kartris.com/Uploads/Images/15faed01-44a6-49f0-a773-1cb6.jpg
The image above is the test promotion that I created.

I think that the difference between our tests might be that I created a single promotion for a product - in this case Test Product No1. Test Product Number 1 has two versions, but its Product Number One itself that is on promotion ( not specifically its versions ).

So when I'm shopping I see that Test Product No1 is on promotion and from within the category section I add 10 x Version 1 (ProdV1) and 4 x Version 2 (ProdV2). This all appears fine in the basket and the checkout, where all applicable discounts are applied.

However, the site will never progress beyond the Checkout stage to payment stages, and produces the database error as mentioned before.

Thanks.

Tiggywiggler
 Posted Thu 9 Feb 2017
Supreme Being

Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)

Group: Forum Members
Last Active: Mon 6 Dec 2021
Posts: 235, Visits: 750
http://forum.kartris.com/Uploads/Images/5c058425-d136-493c-b8d1-15bc.jpg

As you can see, when I add two versions of a product, and I put promotions against each of these two versions, I do not get the error.

In my case the process goes through without an issue.

Can you more clearly explain how you have set up your products so that I can reproduce your issue please?

Here are my two promotions:

http://forum.kartris.com/Uploads/Images/f315ab86-e204-4168-a698-7e8c.jpg

http://forum.kartris.com/Uploads/Images/39bdd733-d678-4c9c-8528-29cf.jpg


We are always willing to help out the community or pitch in to help you fix a problem. However, if you want a complete solution made such as a code module or new feature added you have two options. Either
1) Reach out to the Kartris internal development team at http://www.kartris.com/Contact.aspx.
2) Contact one of the Kartris approved partners at http://www.kartris.com/t-Worldwide-Developers.aspx.

Have fun and good luck coding.
Thu 9 Feb 2017 by Tiggywiggler
SamC
 Posted Thu 9 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
No problem, its good in someways to know that its not something that's gone wrong only with my database or install!

Thanks for the time and availability advice, I'll decide how best to proceed with this issue based on those constraints.

Will this bug have come to the attention of Paul and the development team or do I need to flag it up elsewhere and if there is a resolution to this bug sometime in the future, will it be flagged up on here or elsewhere?

Thanks.
Tiggywiggler
 Posted Thu 9 Feb 2017
Supreme Being

Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)Supreme Being - (124,022 reputation)

Group: Forum Members
Last Active: Mon 6 Dec 2021
Posts: 235, Visits: 750
Thank you for doing the diagnostics on this one Sam, it looks like this is a long term bug.

My comments about people's availability remains the same and so you would need to act based on that advice.


We are always willing to help out the community or pitch in to help you fix a problem. However, if you want a complete solution made such as a code module or new feature added you have two options. Either
1) Reach out to the Kartris internal development team at http://www.kartris.com/Contact.aspx.
2) Contact one of the Kartris approved partners at http://www.kartris.com/t-Worldwide-Developers.aspx.

Have fun and good luck coding.
SamC
 Posted Wed 8 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
I've just run the same test on the latest version of Kartris ( just downloaded and installed ) and have found exactly the same problem occurring.

Is this something that the development team might be able to look at soon?

Maybe we're unusual in having customers ordering promotions in this way, but it does certainly cause quite a problem for us and our customers. I suppose that it does at least explain the mystery of why we've had many customers not being able to complete their orders successfully in the past.

Thanks.
SamC
 Posted Mon 6 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
Oh and by the way the error log recorded exactly the same error message on the clean install as it did on my live version.

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top