StrataFrame Forum

Bug in FillByParent()

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

By fparker - 3/1/2007

If a business object calls its FillByParent() method and the parent's CurrentView contains no rows, the SQL statement that is built will not be properly formatted and a SQLException will be thrown ("incorrect syntax...").  If the parent business object's CurrentDataTable has at least one row, the problem can be worked around by blanking out the RowFilter property of the parent's CurrentView before calling FillByParent() and then reestablishing it after FillByParent() completes.  If you have any questions, let me know. 
By StrataFrame Team - 3/1/2007

Yes, if there are no rows in the parent business object then a FillByParent() should just clear the child business object (since there are no rows to match the parent).  Thanks for the info... I'll make sure that gets fixed.
By Tim Dol - 10/14/2007

Did this problem get resolved in the latest release?  I'm getting an error using FillByParent when the Parent business object is empty. 

Thanks,
Tim

By StrataFrame Team - 10/15/2007

Yes, it should be fixed in the current version.   It's checking on parent.IsEmpty and either clearing or returning the data table according to whether it is a Get or a Fill.  Should be in 6.2.
By StrataFrame Team - 10/15/2007

The latest DLLs have been posted here: http://forum.strataframe.net/FindPost11975.aspx
By Tim Dol - 10/15/2007

Thanks Ben.

Tim

By Tim Dol - 10/15/2007

Sorry Ben, Just want to clarify. Does the code found in the above link solve this problem or do I have to wait until 1.62.

I downloaded and installed the updates (copied to my GAC), but I still get an error with the FillByParent. I'm just wondering if my problem isn't related to this one.

Tim

By StrataFrame Team - 10/16/2007

Hrm, yeah, those DLLs have the fix for FillByParent when the parent is empty.  So, if you're still getting the error, then yes, it might be unrelated.  Could you post the details for the exception that you're receiving?
By Edhy Rijo - 10/16/2007

Ben Chase (10/15/2007)
The latest DLLs have been posted here: http://forum.strataframe.net/FindPost11975.aspx

Hi Ben,

Can/should we all download those DLLs, or will it be an official release shortly to keep everybody in synch?

Thanks!

By StrataFrame Team - 10/16/2007

Yes, there will be an official release in the coming weeks/month.  No official date at the moment, though.
By Tim Dol - 10/16/2007

Hi Ben,

The exception I'm getting when sch_SheduleBO1 is empty is: 'SQL Exception Unhandled by user code' Line 1: Incorrect Syntax Near ')'.

My Code:

Me.Sch_ScheduleBO1.FillAll()

Me.Sch_ScheduleDetailBO1.FillByParent()

If I add 1 record to my Sch_Schedule table, everything works fine.

I also attached the DEBUG information for the two fill methods.

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.get_MetaData()
   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 runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.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.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
   at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)
   at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)
   at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(QueryInformation QueryInfo, OnChangeEventHandler CallBack)
   at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(QueryInformation QueryInfo, Boolean RegisterNotification)
   at MicroFour.StrataFrame.Business.BusinessLayer.FillOrGetByParentPrimaryKey(Object[] ParentPrimaryKeys, Boolean ReplaceCurrentDataTable)
   at MicroFour.StrataFrame.Business.BusinessLayer.FillOrGetByParent(BusinessLayer Parent, Boolean ReplaceCurrentTable)
   at MicroFour.StrataFrame.Business.BusinessLayer.FillByParent()
   at Avanti.Scheduling.frmMain.frmMain_Load(Object sender, EventArgs e) in C:\Source Code\Scheduling\Avanti Scheduling\Avanti Scheduling\Forms\frmMain.vb:line 75
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.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 Tim Dol - 10/19/2007

Just following up to see if I have a problem or if there is a small bug...

Thanks

Tim

By Trent L. Taylor - 10/19/2007

I have not had a chance to set this up, but it would probably be a good idea to just add a test around the DetailBO1 before calling it. 

If ScheduleBO1.Count > 0 Then
    DetailsBO1.FillByParent()
End If

I will look into this though.

By Edhy Rijo - 4/28/2008

Hi Trent,

Just to let you know that today I was bit by the same issue, I got the same error.

Obviously using the count test will work in this case, but I think this should be fixed ASAP.

By Trent L. Taylor - 4/28/2008

From what I can tell the issue is that the parent BO doesn't have any records.  In that case, just test it prior to calling the Fill method...which is better anyway.  This is already on my list.  But you are ALWAYS better off being pre-emptive when dealing with emtpy tables, BOs, etc.
By Edhy Rijo - 4/28/2008

Trent L. Taylor (04/28/2008)
But you are ALWAYS better off being pre-emptive when dealing with emtpy tables, BOs, etc.

Yes, you are right, I have not even noticed that in the same form I was using the BO.count check as you suggested here and was blocked by the error, and even took the time to check the forums before posting.  Well I am still getting used to SF Tongue and so far I love it Hehe