StrataFrame Forum

PrimaryKeyIsAutoIncremented On Save

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

By Derrick Bell - 11/28/2006

I getting the error below when I attempt to save from my form. The linkage field to my two new child BOs is the parent key and not the autoincrementing keys of the Child tables the BO is associated with.

ParentRelationship is the Parent PK to FK in Child.  

BusinessLayerException
 An error occurred while saving an the data to the server.
DataLayerSavingException
 Cannot create INSERT command because a business object with PrimaryKeyIsAutoIncremented = True must have exactly 1 primary key field.
Exception
 Cannot create INSERT command because a business object with PrimaryKeyIsAutoIncremented = True must have exactly 1 primary key field.

Source     : MicroFour StrataFrame Business

Stack Trace:
   at MicroFour.StrataFrame.Data.DataLayer.BuildInsertInfo(DataTable UpdatingTable, Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams)
   at MicroFour.StrataFrame.Data.DataLayer.SaveByForm(DataTable TableToSave, Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save(Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save()
   at MicroFour.StrataFrame.UI.Windows.Forms.DevEx.MaintenanceFormToolbar.cmdSave_ItemClick(Object sender, ItemClickEventArgs e)
   at DevExpress.XtraBars.BarItem.OnClick(BarItemLink link)
   at DevExpress.XtraBars.BarBaseButtonItem.OnClick(BarItemLink link)
   at DevExpress.XtraBars.BarItemLink.OnLinkClick()
   at DevExpress.XtraBars.BarItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
   at DevExpress.XtraBars.BarButtonItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
   at DevExpress.XtraBars.BarItemLink.OnLinkActionCore(BarLinkAction action, Object actionArgs)
   at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.ClickLink(BarItemLink link)
   at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.UnPressLink(BarItemLink link)
   at DevExpress.XtraBars.Controls.CustomLinksControl.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.XtraBars.Controls.DockedBarControl.WndProc(Message& msg)
   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 Trent L. Taylor - 11/28/2006

Do you have a primary key associated with the BO?  Does the table have an auto-incrementing primary key?  I need this information before I can give you any kind of answer.  Thanks. Smile
By Derrick Bell - 11/29/2006

Sorry for the deley we at a network issue late yesterday.

I have a primary key associated with both parent and child BOs
All primary keys areauto-incrementing.
All child BOs linked by the parent BOs primary key.

 

By Trent L. Taylor - 11/29/2006

Well, the message above is telling you that you do not have a primary key on the BO, thus the error message.  Take a screen shot of your BO's in the BO mapper so I can have a visual Smile
By Derrick Bell - 11/29/2006

Here they are. Thanks!

By Derrick Bell - 11/29/2006

What's strange is that all the children have auto-incrementing primary keys. But I notice the key symbol on case_sid in the drivers table. I have no idea how that got marked as a key.
By StrataFrame Team - 11/30/2006

I can't tell which picture you're referring to because the images are so small, but it looks like the top picture has 2 primary key fields.  Most likely your definition of the structure for the table, whether in the DDT or in SQL Server, contains both as part of the primary key for the table.  So, that is what is cauing your error... you can only have 1 primary key field on the business object if the primary key is configured to auto-increment. 

If you cannot determine what is causing both of the fields to be recognized as part of the primary key, you can customize the business object in the BOMapper, by editing it's properties, and override the primary key definition by selecting only the one field that should be the auto-incremented pk.

By Derrick Bell - 11/30/2006

I'll try that