StrataFrame Forum

Adding Child BOs Exception

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

By Derrick Bell - 11/28/2006

I'm adding a child BO that will be called similar to the childBO in your CRM example. Somewhere along the way after I added the child object to the form and configured my second child BO relationship by the primary key(case_sid) I get the following exception when adding a new record:

SyntaxErrorException

            Syntax error: Missing operand after 'case_sid' operator.

 

All of my fields are locked on the form until I either remove the childBO from my maintenance form or eliminate the relationship with the Parent BO. In the mean time I've added my third business object without error. The issue is probably some tweak of the object, but I cant figure it out. I thought the exception might be familar to you.

Derrick Bell

By StrataFrame Team - 11/28/2006

Generally, those syntax error operations come from trying to set the filter on the view, or do a Select() within the CurrentDataTable.  Could you post the stack trace for the exception so I can see where the exception is manifesting?
By Derrick Bell - 11/28/2006

Here is the stack trace:

Stack Trace:

   at System.Data.ExpressionParser.Parse()

   at System.Data.DataExpression..ctor(DataTable table, String expression, Type type)

   at System.Data.DataView.set_RowFilter(String value)

   at MicroFour.StrataFrame.Business.BusinessLayer.set_Filter(String value)

   at MicroFour.StrataFrame.Business.BusinessLayer.FilterChildRecords(BusinessLayer ChildBusinessObject)

   at MicroFour.StrataFrame.Business.BusinessLayer.Navigate(BusinessNavigationDirection Direction, Int32 AbsoluteIndex, Object[] PrimaryKeyValues, Boolean AttemptToCheckRules, Boolean IsRefill)

   at MicroFour.StrataFrame.Business.BusinessLayer.Add(Boolean CheckSecurity)

   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Add(Boolean CheckSecurity)

   at MicroFour.StrataFrame.UI.Windows.Forms.DevEx.MaintenanceFormToolbar.cmdNew_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 StrataFrame Team - 11/28/2006

Yep, happened while you were trying to set the filter on the child records... what are the primary and foreign key fields, and what is the value of the primary key in the parent record when the exception is thrown?
By Derrick Bell - 11/28/2006

I might have been trying to do too much at once. When I initially added the ChildBO, I configured the parent-child properties immediately. Is this okay? Or should I build solution first?

Second there might be issues with the underlying database changing keys, so I deleted the object and it's mapping. Dropped and rebuilt the database table and am in the process of reviewing.

Derrick

By Derrick Bell - 11/28/2006

There is no key yet because I'm adding a new reocrd.

Derrick

By Derrick Bell - 11/28/2006

Seems the error is occuring with the setting of the ParentBusinessObject in any new child objects I add.

The primaryKey of Parent table is: caseid this is the also the FK in my child objects

I check if parent records exist before populating the children:

Private Sub Cite1_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles Cite1.Navigated

     '-- Make sure there are records in the citation BO, otherwise
     ' an error will occur.

     If Cite1.Count > 0 Then
     '-- Load the childBOs
          Me.Driver1.FillByParentPrimaryKey(Cite1.case_sid)
          Me.Officer1.FillByParentPrimaryKey(Cite1.case_sid)
          Me.Violations1.FillByParentPrimaryKey(Cite1.case_sid)
     '-- Requery the officer list
          Me.lstOfficers.Requery()
     End If

End Sub

Note my first child object Driver1 is working properly. Working with Trent we set the following settings on the Parent object Cite1 and the Driver child object.

IncludeFormAdd: True
IncludeFormEdit: True
IncludeFormDelete: True
IncludeFormSave: True

Would these setting affect workings of the two new child objects I'm trying to add?

adfadfasd

By StrataFrame Team - 11/28/2006

At the point when the exception is thrown, the new record will have already been added to the business object... I was just wondering if the primary key for the record was a negative number or if it was NULL.
By StrataFrame Team - 11/28/2006

You said that the Driver1 business object gets filtered correctly... there was a bug in the FilterChildRecords() method that caused it to fail if the parent business object attempted to filter more than one child business object because the filter was not correctly reset after each iteration through the child business objects... I thought that you were the one that found the bug, but maybe not.  It was resolved last week, so it this might just be a bug that was resolved and you just need the latest version.
By Derrick Bell - 11/28/2006

That could be it. I'll Download the latest and let you know.

Derrick

By StrataFrame Team - 11/28/2006

Keep me posted...
By Derrick Bell - 11/28/2006

That was it.. the error is gone now. On to new horizons.

Derrick

By StrataFrame Team - 11/28/2006

Good, I'm glad that fixed it... I would have mentioned something earlier, but for some reason, I was thinking you were the one that found the bug and already had the fix for it.  Oh well Smile