Violation of PRIMARY KEY Constraint Error in Browser when Checking Out (252707)
The information in this article applies to:
- Microsoft Site Server 3.0 Commerce Edition
This article was previously published under Q252707 SYMPTOMS
When a shopper attempts to check out, he or she may receive the following error message:
Violation of PRIMARY KEY constraint 'PK_(sitename)_receipt'. Cannot insert duplicate key in object '(sitename)_receipt'
CAUSE
This error can be caused by executing the purchase pipeline (from xt_orderform_purchase.asp) to complete an order but then not calling the DeleteData method, following, after the purchase has been completed successfully.
MSCSOrderFormStorage.DeleteData(null, mscsOrderForm)
The DeleteData method removes the purchased basket from the (sitename)_basket table. If the basket is not removed but the contents of the basket were purchased, the next time the shopper visits the site he or she will see the contents of the old basket (the previously purchased contents). If the shopper then "empties" the basket and adds new items to the basket and tries to check out using this old basket, the error will result.
This behavior occurs because the receipt table has the basket's "order_id" as its primary key. If a new basket/order_id is not generated for the shopper after each successful purchase, the shopper will unknowingly be using the old basket/order_id that has already been inserted into the receipt table (during a previous check-out) and thus he or she receives the primary key constraint violation error during execution of the "SaveReceipt" component in the purchase pipeline.
Note that if you turn on transacted pipeline logging, you will see this error in the pipeline log during execution of the "SaveReceipt" component.
RESOLUTION
This condition does not arise on any of the default sample sites or on custom wizard-generated sites. It seems that this error can only occur because of a failure to call the MSCSOrderFormStorage.DeleteData method after each successful purchase. You should check the logic of your xt_orderform_purchase.asp to ensure that the DeleteData method is called after each successful purchase to resolve this issue.
STATUS
Steps to reproduce this behavior:
- Open up your site's xt_orderform_purchase.asp page.
- Do a find for MSCSOrderFormStorage.DeleteData(null, mscsOrderForm) and type the word REM in front of that line.
- Save the xt_orderform_purchase.asp page.
- Visit the site and add items to your basket. Check out.
- After checking out, revisit the site and view your basket. Note that the items from the previous purchase are still listed in your basket.
- Empty your basket, add new items to your basket, and attempt to check out again. You should receive the error.
Modification Type: | Major | Last Reviewed: | 6/29/2004 |
---|
Keywords: | kbprb KB252707 |
---|
|