ArreniA : exception « DevExpress.Xpo.DB.Exceptions.SqlExecutionErrorException…into [Lot]…table ‘CouleurLot’  » (ou TailleLot)

6 février 2020

Si vous rencontrez cette exception dans ArreniA :

« DevExpress.Xpo.DB.Exceptions.SqlExecutionErrorException: Exécution de SQL ‘parameters [@p0] currency,[@p1] currency,[@p2] currency,[@p3] currency,[@p4] currency,[@p5] currency,[@p6] currency,[@p7] currency,[@p8] currency,[@p9] currency,[@p10] currency,[@p11] currency,[@p12] currency,[@p13] currency,[@p14] currency,[@p15] LONGTEXT,[@p16] bit,[@p17] int;insert into Lotvalues(null,null,[@p0],[@p1],[@p2],[@p3],[@p4],[@p5],[@p6],[@p7],[@p8],[@p9],[@p10],[@p11],[@p12],[@p13],[@p14],null,[@p15],null,null,[@p16],[@p17],null,null)’ avec les paramètres ‘{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{_},{False},{927}’ exception ‘System.Data.OleDb.OleDbException (0x80004005): Vous ne pouvez pas ajouter ou modifier un enregistrement car l’enregistrement associé est requis dans la table ‘CouleurLot’.
à System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
à System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
à System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
à System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
à System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
à System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
à DevExpress.Xpo.DB.ConnectionProviderSql.<>c__DisplayClass117_0.b__0()
à DevExpress.Xpo.Logger.LogManager.Log[T](String category, LogHandler1 handler, MessageHandler1 createMessageHandler)
à DevExpress.Xpo.DB.ConnectionProviderSql.InternalExecSql(IDbCommand command)
à DevExpress.Xpo.DB.ConnectionProviderSql.ExecSql(Query query)’ —> System.Data.OleDb.OleDbException: Vous ne pouvez pas ajouter ou modifier un enregistrement car l’enregistrement associé est requis dans la table ‘CouleurLot’.
à System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
à System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
à System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
à System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
à System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
à System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
à DevExpress.Xpo.DB.ConnectionProviderSql.<>c__DisplayClass117_0.b__0()
à DevExpress.Xpo.Logger.LogManager.Log[T](String category, LogHandler1 handler, MessageHandler1 createMessageHandler)
à DevExpress.Xpo.DB.ConnectionProviderSql.InternalExecSql(IDbCommand command)
à DevExpress.Xpo.DB.ConnectionProviderSql.ExecSql(Query query)
— Fin de la trace de la pile d’exception interne —
à DevExpress.Xpo.DB.ConnectionProviderSql.ExecSql(Query query)
à DevExpress.Xpo.DB.AccessConnectionProvider.GetIdentity(Query sql)
à DevExpress.Xpo.DB.ConnectionProviderSql.GetIdentity(InsertStatement root, TaggedParametersHolder identities)
à DevExpress.Xpo.DB.ConnectionProviderSql.DoInsertRecord(InsertStatement root, TaggedParametersHolder identities)
à DevExpress.Xpo.DB.ConnectionProviderSql.UpdateRecord(ModificationStatement root, TaggedParametersHolder identities)
à DevExpress.Xpo.DB.ConnectionProviderSql.ProcessModifyData(ModificationStatement[] dmlStatements)
à DevExpress.Xpo.DB.DataStoreSerializedBase.ModifyData(ModificationStatement[] dmlStatements)
à DevExpress.Xpo.DB.ConnectionProviderSql.ModifyData(ModificationStatement[] dmlStatements)
à DevExpress.Xpo.SimpleDataLayer.<>c__DisplayClass6_0.b__0()
à DevExpress.Xpo.SimpleDataLayer.ReentrancyAndThreadSafetyChecked[T](Func`1 action)
à DevExpress.Xpo.SimpleDataLayer.ModifyData(ModificationStatement[] dmlStatements)
à DevExpress.Xpo.SimpleObjectLayer.CommitChanges(Session session, ICollection fullListForDelete, ICollection completeListForSave)
à DevExpress.Xpo.Session.FlushChangesInsideTransaction()
à DevExpress.Xpo.Session.FlushChanges()
à DevExpress.Xpo.Session.ProcessingProcess(ObjectSet markedObjectsHolder, Object theObject)
à DevExpress.Xpo.Session.Save(Object theObject)
à IntelliX.TFJ.Core.ProductCreation.createLot(Session uow, Produit produit)
à IntelliX.TFJ.Core.ProductCreation.createProduct(Session session, ProductDef productDef)
à IntelliX.TFJ.Core.ProductCreation.CreateListProduct(XElement xml)
à IntelliX.TFJ.Core.ProductCreation.Create(XElement xml) »

Pour régler ce problème il suffit de positionner la valeur par défaut de cleCouleur et cleTaille dans la table Lot à Null. Pour cela, ouvrez la table Lot en mode création (design view).

Dans la Valeur par défaut (Default Value), saisissez Null pour les deux valeurs cleCouleur et cleTaille.