Generic SQL error when deleting Contract
-
viernes, 15 de junio de 2012 14:05
Hi,
I'm getting a generic sql error when deleting canceled contract. This is the trace :
at ExceptionConverter.ConvertMessageAndErrorCode(Exception exception, Int32& errorCode)
at ExceptionConverter.ToSingleFaultOther(Exception exception)
at ExceptionConverter.ToSingleFaultUntyped(Exception exception)
at ExceptionConverter.ConvertToFault(Exception exception)
at ExceptionConverter.TryConvertToFaultExceptionInternal(Exception exception, Boolean createNewFaultException, FaultException`1& faultException)
at FaultHelper.ConvertToFault(Exception exception)
at OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)
at InprocessServiceProxy.ExecuteCore(OrganizationRequest request)
at PlatformCommand.XrmExecuteInternal()
at DataSource.Delete(String entityName, Guid entityId, IOrganizationContext context)
at EntityProxy.Delete()
at Contract.Delete()
at DeleteDialogPage.ConfigureForm()
at AppUIPage.OnPreRender(EventArgs e)
at Control.PreRenderRecursiveInternal()
at Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at Page.ProcessRequest()
at Page.ProcessRequest(HttpContext context)
at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
>System.Data.SqlClient.SqlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #33C78465: System.Data.SqlClient.SqlException (0x80131904): Violation de la contrainte PRIMARY KEY 'PK__fn_Colle__6156C8193B783965'. Impossible d'insérer une clé en double dans l'objet 'dbo.@t'.
> at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
> at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
> at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
> at System.Data.SqlClient.SqlDataReader.HasMoreRows()
> at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout)
> at Microsoft.Crm.CrmDataReader.Read()
> at Microsoft.Crm.BusinessEntities.CrmCascadeDBHandler.<>c__DisplayClass1.<CollectForCascadeWrapper>b__0(IDbCommand cmd)
> at Microsoft.Crm.BusinessEntities.CrmCascadeDBHandler.Collect(String cascadingSql, Int32 entityOtc, ExecutionContext context, CollectDelegate CollectDelegate)
> at Microsoft.Crm.BusinessEntities.CrmCascadeDBHandler.CollectForDelete(IEnumerable`1 entityIds, Int32 entityOtc, ExecutionContext context)
> at Microsoft.Crm.BusinessEntities.CascadeEngine.CascadeDeleteDB(IEnumerable`1 parentEntityIds, Int32 parentEntityObjectTypeCode, ExecutionContext context)
> at Microsoft.Crm.BusinessEntities.CascadeEngine.Delete(IEnumerable`1 entityIds, Int32 entityObjectTypeCode, ExecutionContext context)
> at Microsoft.Crm.BusinessEntities.BusinessProcessObject.Delete(BusinessEntityMoniker moniker, ExecutionContext context)
Thanks in advance.
Todas las respuestas
-
sábado, 16 de junio de 2012 8:16
Hi,
Cancelled contracts cannot be deleted.
Thanks...
-
martes, 24 de julio de 2012 9:01
Canceled contracts could be deleted, I have deleted some canceled contracts, but others cannot be deleted because of the same generic SQL errorCancelled contracts cannot be deleted.
-
martes, 24 de julio de 2012 10:25Moderador
The error looks like it comes from when CRM tries to do a cascaded delete. During this process CRM populates a temporary table with the child data to delete, and it looks like 2 records have the same primary key. I would expect the primary key would be that of the original data, so somehow there are 2 records (probably from different child entities of the contract) that have the same primary key. This could occur if the data were imported using explicitly provided primary keys.
One way to resolve this is to try and delete all the child entities manually before deleting the contract. Another option would be to change the cascade behaviour of the relationships prior to deleting the contract, though this would leave orphaned records
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk
- Editado DavidJennawayMVP, Moderator martes, 24 de julio de 2012 10:26
-
martes, 24 de julio de 2012 10:38I have checked it, and there is no child records for the contract