Violation of PRIMARY KEY constraint 'PK_TeaCommerce_CustomProperty' after changing Order Status
Once we've catured a payment using the SagePay test gateway we are able to change the status of the order no problem. However, after we have clicked the 'capture payment' button in the interface when we try to change status we get the following error:
Violation of PRIMARY KEY constraint 'PK_TeaCommerce_CustomProperty'. Cannot insert duplicate key in object 'dbo.TeaCommerce_CustomOrderProperty'. The duplicate key value is (21475660-9b45-433b-b8fc-465070de123e, vendorTxCode). The statement has been terminated.
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Data.SqlClient.SqlException (0x80131904): Violation of PRIMARY KEY constraint 'PK_TeaCommerce_CustomProperty'. Cannot insert duplicate key in object 'dbo.TeaCommerce_CustomOrderProperty'. The duplicate key value is (21475660-9b45-433b-b8fc-465070de123e, vendorTxCode).
The statement has been terminated.
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)
It sounds weird that the order status should have anything to do with this. Could you try and just click the capture button and see if that generates the error. If not Then try and recycle your website and load the edit order again and then only change the status. See if that generates the error. Just try to pin point what exactly generates the error :)
Moving to PAYMENT rather than AUTHORISE fixed this problem which is what we wanted in any case. I think that this might be same root cause as the issue below so hopefully the fix would work for this too.
Violation of PRIMARY KEY constraint 'PK_TeaCommerce_CustomProperty' after changing Order Status
Once we've catured a payment using the SagePay test gateway we are able to change the status of the order no problem. However, after we have clicked the 'capture payment' button in the interface when we try to change status we get the following error:
Violation of PRIMARY KEY constraint 'PK_TeaCommerce_CustomProperty'. Cannot insert duplicate key in object 'dbo.TeaCommerce_CustomOrderProperty'. The duplicate key value is (21475660-9b45-433b-b8fc-465070de123e, vendorTxCode).
The statement has been terminated.
Log shows:
2013-05-01 08:38:10,399 [6] ERROR Umbraco.Core.UmbracoApplicationBase - [Thread 3] An unhandled exception occurred
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Data.SqlClient.SqlException (0x80131904): Violation of PRIMARY KEY constraint 'PK_TeaCommerce_CustomProperty'. Cannot insert duplicate key in object 'dbo.TeaCommerce_CustomOrderProperty'. The duplicate key value is (21475660-9b45-433b-b8fc-465070de123e, vendorTxCode).
The statement has been terminated.
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 TeaCommerce.Api.Persistence.Database.Insert(String tableName, String primaryKeyName, Boolean autoIncrement, Object poco)
at TeaCommerce.Api.Persistence.Database.Insert(Object poco)
at TeaCommerce.Api.Persistence.Repositories.OrderRepository.Save(Order order)
at TeaCommerce.Api.Models.Order.Save()
at TeaCommerce.Umbraco.Application.Views.Orders.EditOrder.BtnSave_Click(Object sender, ImageClickEventArgs e)
at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
ClientConnectionId:e382570d-ea64-4410-b7ab-ad4b4d5fff5e
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Hi Mark
It sounds weird that the order status should have anything to do with this. Could you try and just click the capture button and see if that generates the error. If not Then try and recycle your website and load the edit order again and then only change the status. See if that generates the error. Just try to pin point what exactly generates the error :)
And by the way - remember to update to 2.1 as there was an error in the order save stuff. Be aware of the breaking changes - http://documentation.teacommerce.net/revision-history/
The breaking changes about the order properties being formatted in a new way can be found here how to do it correctly:
http://documentation.teacommerce.net/html-api/order-property/addorupdateorderproperties/
Kind regards
Anders
Hi Anders,
Moving to PAYMENT rather than AUTHORISE fixed this problem which is what we wanted in any case. I think that this might be same root cause as the issue below so hopefully the fix would work for this too.
http://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/40556-Tea-Commerce-Newbie-Questions
Thanks,
Mark
is working on a reply...