StrataFrame Forum

Error retrieving primary key

http://forum.strataframe.net/Topic2083.aspx

By Andria Jensen - 8/3/2006

When I try to add a new record to my business object, I am getting the following error.  The business object has records in it, and I can access the primary key field in debug.  I can edit and save a record, just can't add new.  Not sure what the problem is here, but please offer a suggestion.

8/3/2006 1:30:11 PM
Source: MicroFour StrataFrame Business
Message: An error occurred while retrieving the primary key from the parent business object.
Stack:    at MicroFour.StrataFrame.Business.BusinessLayer.NewRow()
   at MicroFour.StrataFrame.Business.BusinessLayer.Add(Boolean CheckSecurity)
   at MicroFour.StrataFrame.Business.BusinessLayer.Add()
   at BBS.GUI.BaseControls.MaintStrip.button_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at DevExpress.XtraEditors.BaseButton.OnClick(EventArgs e)
   at DevExpress.XtraEditors.BaseButton.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at DevExpress.XtraEditors.BaseControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

By StrataFrame Team - 8/3/2006

There should be an inner exception that will contain more detailed information.  Most likely, the parent business object does not have any records in it, and so you cannot add a record to the child because the child business object is trying to maintain the relationship to the parent. 

Check the inner exception.  If it says something like "could not evaluate current row Count:0, CurrentRowIndex: -1 then there is no parent record for the children you are trying to add.

By Trent L. Taylor - 8/3/2006

It looks as though you have a relationship established between this business object and another.  Do you have the ParentBusinessObject property set?  It is as though it is attempting to get the primary key value of the parent BO, but either the parent business object is not set properly or the field it is requesting is not available.  If both of these are set properly, is there a valid record set as the current index of the parent business object?
By Andria Jensen - 8/3/2006

Yep, I had the parent relationship reversed.  The child was supposed to be the parent, and vice versa.  I fixed that and it works great now.  Thanks for the help!
By StrataFrame Team - 8/3/2006

No problem Smile