﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » BusinessLayerException error message</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Thu, 28 May 2026 14:24:29 GMT</lastBuildDate><ttl>20</ttl><item><title>BusinessLayerException error message</title><link>http://forum.strataframe.net/FindPost11530.aspx</link><description>Hi All,&lt;P&gt;I am testing on a simple form with a one field and when trying to save I got the error below:&lt;/P&gt;&lt;P&gt;[quote]BusinessLayerException&lt;BR&gt;&amp;nbsp; An error occurred while saving an the data to the server.&lt;BR&gt;DataLayerSavingException&lt;BR&gt;&amp;nbsp; The INSERT statement conflicted with the FOREIGN KEY constraint "Relation_203". The conflict occurred in database "ATR", table "dbo.Buildings", column 'PK_Buildings'.&lt;BR&gt;The statement has been terminated.&lt;BR&gt;SqlException&lt;BR&gt;&amp;nbsp; The INSERT statement conflicted with the FOREIGN KEY constraint "Relation_203". The conflict occurred in database "ATR", table "dbo.Buildings", column 'PK_Buildings'.&lt;BR&gt;The statement has been terminated.&lt;/P&gt;&lt;P&gt;Source&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : MicroFour StrataFrame Business&lt;BR&gt;[/quote]&lt;P&gt;The table ServiceCalls is related to the table Buildings, but in the form only a ServiceCallsBO is in place.&lt;P&gt;I will appreciate if anybody could help me figure out what may be wrong in this case.&amp;nbsp; I am new to SF, VB.NET &amp;amp; MS-SQL Express 2005.&amp;nbsp; My background is with Visual FoxPro.&lt;P&gt;Thanks</description><pubDate>Wed, 19 Sep 2007 13:56:34 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: BusinessLayerException error message</title><link>http://forum.strataframe.net/FindPost11602.aspx</link><description>Hi Ben,&lt;/P&gt;&lt;P&gt;Once again, thanks for your input.&amp;nbsp; Now I know how to get there in either case.</description><pubDate>Wed, 19 Sep 2007 13:56:34 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: BusinessLayerException error message</title><link>http://forum.strataframe.net/FindPost11594.aspx</link><description>We help along the referential integrity by setting foreign key values when you specify a relationship within the business objects, but we don't enforce referential integrity; that's the sole responsibility of the database.&lt;/P&gt;&lt;P&gt;As for using a dummy record, there are a couple of ways you could go about doing this.&amp;nbsp; You could know the PK ahead of time, either because you manually assigned it (IDENTITY INSERT ON) and always use the same PK, or because you put a flag on the record and retrieve it when you start up the application.&amp;nbsp; Either way you would have the PK in a shared variable or a constant somewhere that would allow you to assign the value within the SetDefaultValues() of a business object.&amp;nbsp; So, records would start out bound to that dummy record unless the user chooses to assign them to a different building.&lt;/P&gt;&lt;P&gt;Like I said, though, you certainly don't have to use a dummy record, and if keeping track of the dummy record is a pain, then using 0 (which you would always know) would certainly work, too, but you would have to turn off the enforcing of your PK (cascading deletes/updates would still work, though because you have the relationship defined, turning off the enforcement only prevents the DB from throwing an exception when the relationship isn't followed).</description><pubDate>Wed, 19 Sep 2007 13:00:14 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: BusinessLayerException error message</title><link>http://forum.strataframe.net/FindPost11586.aspx</link><description>[quote][b]Ben Chase (09/19/2007)[/b][hr]Your only other option would be to enforce the relationship, but create a "dummy" building record that is the "catch-all" for the service calls that don't have a building.&amp;nbsp; That way, you end up with a "&amp;lt;No Building Assigned&amp;gt;" building record and all of the service calls are still attached to a building, but might be attached to that one.[/quote]&lt;/P&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;Thanks for the confirmation and your new idea above, I do like it and I am considering implementing the dummy&amp;nbsp; building record.&amp;nbsp; If it is not too much to ask, could you elaborate a bit on this idea on how to accomplish this with SF?&amp;nbsp; So far I know I can create the record manually with specific PK or add another field to flag this record as a dummy one, but then how to tell the ServiceCalls form to use that record for non assigned building?&amp;nbsp; Is the answer by knowing ahead of time the PK or the flag field of the dummy record and setting it as default for the combobox lookup field of the ServiceCallsBO?&lt;/P&gt;&lt;P&gt;Also another question, does SF has anything to do with handling the enforcement of referential integrity or it is the sole responsibility of the database to handle that?</description><pubDate>Wed, 19 Sep 2007 12:45:10 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: BusinessLayerException error message</title><link>http://forum.strataframe.net/FindPost11574.aspx</link><description>If the ServiceCall is the child, but it does not necessarily have a building as it's parent, then yes, you changed the correct property.&amp;nbsp; Your only other option would be to enforce the relationship, but create a "dummy" building record that is the "catch-all" for the service calls that don't have a building.&amp;nbsp; That way, you end up with a "&amp;lt;No Building Assigned&amp;gt;" building record and all of the service calls are still attached to a building, but might be attached to that one.&lt;/P&gt;&lt;P&gt;It all makes sense on the way you want to query the records.&amp;nbsp; If you want to join the ServiceCalls to the Buildings table, you will have to to an OUTER JOIN to get the ServiceCalls that don't have an assigned building.&amp;nbsp; Where as, if you create the dummy record, both an INNER JOIN and an OUTER JOIN will retrieve the records.&amp;nbsp; It's all up to you.</description><pubDate>Wed, 19 Sep 2007 09:04:58 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: BusinessLayerException error message</title><link>http://forum.strataframe.net/FindPost11558.aspx</link><description>[quote][b]Trent L. Taylor (09/18/2007)[/b][hr]Yeah, this goes back to my eariler point.&amp;nbsp; First, you have a BO that represents the Buildings table I assume.&amp;nbsp; This is the table that you are trying to update.&amp;nbsp; So does the primary key field auto-increment or do you have to provide the primary key.&amp;nbsp; Second, it is a child of ServiceCalls so the value that is in the PK_Buildings field violates the relationship.&amp;nbsp; So the first thing to address is that the primary key is being auto-incremented by the server or provided by you somehow.&amp;nbsp; Next, you may need to review the relationship (Relation_203) to see if a parent record is required.&amp;nbsp; If so, then you may have to have a ServiceCalls record which the Buildings is associated with (I think this is less likely).[/quote]&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;For testing pupose&lt;/EM&gt;&lt;/STRONG&gt; I went to the Relation properties in SQLExpress Manager console&amp;nbsp;and set "Enforce Foreign Key Constraint = No" and that allow the record to be saved, even thought I am not so sure what this setting may break .&lt;/P&gt;&lt;P&gt;Now to explain better my settings, I have a form to handle the ServiceCalls data with a ServiceCallsBO.vb class, I add just one field CustomerName and when trying to save I got the initial error in the first message.&lt;/P&gt;&lt;P&gt;ServiceCalls is a child table of the Building table, so eventually in this form I will have a combobox to&amp;nbsp;lookup the building data, but so far I am just testing with a plain and simple field.&amp;nbsp; All primary fields in both tables are auto-incremented.&amp;nbsp; &lt;/P&gt;&lt;P&gt;To resume, in this case a ServiceCall record may have a Building record associated with it, but not necessarily, so is the changed I did above in the relation correct?&lt;/P&gt;&lt;P&gt;Thanks!</description><pubDate>Tue, 18 Sep 2007 15:51:19 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: BusinessLayerException error message</title><link>http://forum.strataframe.net/FindPost11553.aspx</link><description>Yeah, this goes back to my eariler point.&amp;nbsp; First, you have a BO that represents the Buildings table I assume.&amp;nbsp; This is the table that you are trying to update.&amp;nbsp; So does the primary key field auto-increment or do you have to provide the primary key.&amp;nbsp; Second, it is a child of ServiceCalls so the value that is in the PK_Buildings field violates the relationship.&amp;nbsp; So the first thing to address is that the primary key is being auto-incremented by the server or provided by you somehow.&amp;nbsp; Next, you may need to review the relationship (Relation_203) to see if a parent record is required.&amp;nbsp; If so, then you may have to have a ServiceCalls record which the Buildings is associated with (I think this is less likely).</description><pubDate>Tue, 18 Sep 2007 15:03:37 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: BusinessLayerException error message</title><link>http://forum.strataframe.net/FindPost11542.aspx</link><description>[quote][b]Trent L. Taylor (09/18/2007)[/b][hr]This is a message that is being returned by SQL Server.&amp;nbsp; A foreign key relationship is setup on the table but you did not provide a primary key or a foreign key.&amp;nbsp; You generally see this more on child records.&amp;nbsp; But it is possible that you have a PK that is not autoincrementing and you did not provide a value for the PK.[/quote] &lt;P&gt;Hi Trent,&lt;/P&gt;&lt;P&gt;This is a bit confusing for me since I use xCase to design my data and relationship are usually created automatically.&amp;nbsp; There are other tables which also has relations and does not generate this error.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Let me provide more detail about this table and its related table:&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Main Table Name: &lt;STRONG&gt;ServiceCalls&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;P&gt;&amp;nbsp;PRIMARY FIELD: &lt;STRONG&gt;PK_ServiceCalls&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;FOREING FIELD: FK_Buildings&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;UL&gt;&lt;LI&gt;Lookup Table: &lt;STRONG&gt;Buildings&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;P&gt;PRIMARY FIELD: &lt;STRONG&gt;PK_Buildings&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;In the form, only the ServiceCalls data is used with a SF BO, I setup this form with the same procedure as the others I have done while testing and this is the only one giving me that error.&amp;nbsp; Please notice in the image the relation detail for relation named Relation_203.&amp;nbsp; Just so you know, these two tables has not records, and both Primary fields are AutoIncremented by the server.</description><pubDate>Tue, 18 Sep 2007 12:58:49 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: BusinessLayerException error message</title><link>http://forum.strataframe.net/FindPost11536.aspx</link><description>This is a message that is being returned by SQL Server.&amp;nbsp; A foreign key relationship is setup on the table but you did not provide a primary key or a foreign key.&amp;nbsp; You generally see this more on child records.&amp;nbsp; But it is possible that you have a PK that is not autoincrementing and you did not provide a value for the PK.</description><pubDate>Tue, 18 Sep 2007 11:28:13 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>