Parent - Child relationship BO using DevExpress Grid


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yes.  And the reason you got the error is because the Enforce FK Contraints is set to True without cascading the delete. 
Randy Moore
Randy Moore
StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)
Group: Forum Members
Posts: 12, Visits: 140
I figured it wouldn't have anything to do with SF. Here's my relationships:

Is that what you meant by cascade?

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
THis has nothing to do with StrataFrame, but rather you FK definitions on your SQL Server.  The message it telling you that you have a FK relationship between the parent and child records and that child records exist.  To resolve this, update your FK relationship on the SQL Server side to cascade the deletions to the child records.  This will eliminate the error.
Randy Moore
Randy Moore
StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)
Group: Forum Members
Posts: 12, Visits: 140
Here's the message that I get when I try to delete a record from the Parent BO:

   The DELETE statement conflicted with the REFERENCE constraint "FKRoofsJobs". The conflict occurred in database "StarkMasterDB", table "dbo.Roofs", column 'JobID'.
  The statement has been terminated.
 
  Exception (SqlException): Source=".Net SqlClient Data Provider"; Target=null; Tag=null; Class=16; LineNumber=1; Number=547; Procedure=""; Server="1lprmoore"; State=0; ErrorCode=-2146232060;

The Jobs table is the parent, with primary key JobID. Roofs is the child with FK JobID. There may be a problem in the DB since I have been adding to the jobs table before all the relationships were in place. I was going to recreate the DB and enter data through the app? What do you think.

  
    

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Well, you went straight to the next step, which is good Smile  What is the error you are getting on the delete?
Randy Moore
Randy Moore
StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)
Group: Forum Members
Posts: 12, Visits: 140
Trent,

Yes, I have already looked at that sample application. I double-checked all the settings of my Child BO's, all relationships and ParentBusinessObject properties are configured properly. I changed the Form Include properties to be:

Seems to be working now except for deleting a parent record.

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Well, let's take the grid out of the forumula because this will only complicate the concept.  The grid is not any part of the forumla in this case.  You are correct the SF will automatically handle the FK relationship, so I am willing to bet that you are having one of two issues.

One, the relationship is not defined (which I think you have already done this).  So two, did you set the ParentBusinessObject property of the child BO?

The above picture is taken from the property sheet of the CRM Sample Application that ships with StrataFrame.  This is the CustomerCreditCards BO on the CustomerMaintenance form.  I recommend looking CRM Sample Application so that you can see how these BOs need to be configured in order for the FK to be automatically managed.

Randy Moore
Randy Moore
StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)StrataFrame Beginner (14 reputation)
Group: Forum Members
Posts: 12, Visits: 140
I have a Maintenance form in which I have dropped a DevExpress grid populated by a BBS bound to a Parent BO. I have also placed five other grids each in their own tab and each being populated by separate BBS's and Child BO's. I have set up the relationships of the child BO's through the designer and set the parent BO property of each child. It works fine when navigating records and the child records display as expected. I can pick a Parent record, and edit the child records, it saves and edits fine. The problem is when I try to add a Parent record and save I get an exception saying that I can't insert a null value into a field. I was under the impression that when a Parent/Child relationship is setup, SF will manage the foreign keys.

I need to lock down the parent grid but leave the child grids editable. When the user clicks edit, it unlocks the parent grid and locks the child grid until a save is made. 

Here is one of the exceptions I get:

Exception (BusinessLayerException): Source="MicroFour StrataFrame Business"; Target=null; Tag=null;
    Message = "An error occurred while saving an the data to the server."
    InnerException (DataLayerSavingException): Source="MicroFour StrataFrame Business"; Target=null; Tag=null;
      Message =
          "Cannot insert the value NULL into column 'FramerID', table 'StarkMasterDB.dbo.Framers'; column does not allow nulls. INSERT fails.
          The statement has been terminated."
      StackTrace =
          "   at MicroFour.StrataFrame.Data.DataLayer.SaveByForm(DataTable TableToSave, Boolean Transactional, String TransactionKey)
             at MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey)"
      InnerException (SqlException): Message=(->Message); Source=".Net SqlClient Data Provider"; Target=null; Tag=null; Class=16; LineNumber=1; Number=515; Procedure=""; Server="1lprmoore"; State=2; ErrorCode=-2146232060;
        StackTrace =
            "   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
               at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
               at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
               at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
               at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
               at System.Data.SqlClient.SqlDataReader.getMetaData()
               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)
               at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior ... (truncated) ...Command.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
               at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
               at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
               at System.Data.Common.DbCommand.ExecuteReader()
               at MicroFour.StrataFrame.Data.DbDataSourceItem.InternalExecuteReader(DbCommand Command, Boolean IsTransactional, String TransactionKey)
               at MicroFour.StrataFrame.Data.SqlDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand)
               at MicroFour.StrataFrame.Data.DbDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler)
               at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams)"
        Errors (SqlErrorCollection): Count=2;
          #0 = {System.Data.SqlClient.SqlError: Cannot insert the value NULL into column 'FramerID', table 'StarkMasterDB.dbo.Framers'; column does not allow nulls. INSERT fails.}
          #1 = {System.Data.SqlClient.SqlError: The statement has been terminated.}
      SaveErrors (DataLayerSaveErrorCollection): Count=1;
        #0 = MicroFour.StrataFrame.Data.DataLayerSaveError
 
  Environment:  ThreadIdentity="" DateTime=["2007-02-02 10:22:55.081"] ThreadName=null WindowsIdentity="STRUSS\RMoore" ThreadId="11" DemoVersion="True" DomainName=["Project Tracker.vshost.exe"] OSVersion=["Microsoft Windows NT 5.1.2600 Service Pack 2"] MachineName="1LPRMOORE" UserName="RMoore"
  
  

 Any insight as to what happens to the Parent and Child BO's when the edit, save, delete, and new buttons are clicked on the maintenace toolstrip would be helpful.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search