StrataFrame Forum

Error on Delete

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

By Scott - 12/13/2005

When deleting the last record in a table I get an indexoutofrange exception.  Any Ideas.
By StrataFrame Team - 12/13/2005

OK, I just went through trying to reproduce your error. I started with 3 records in the business object and called DeleteCurrentRow on all 3 both by only marking them as deleted and by deleting them directly from the server. Never got an IndexOutOfRangeException.



Is your business object's editing state Idle, Editing, or Adding? While you gather me some more info on your scenario, I'm going to go look at the code and see if I can find find anything obvious.
By StrataFrame Team - 12/13/2005

Can you attach a screenshot of the red error window you're receiving? It should have the stack trace on it, and that should help.
By Scott - 12/13/2005

Here is the trace stack,  I am almost sure I messed something up I just don't know what it is.

BusinessLayerException
 An error occurred while trying to delete the specified row.
BusinessLayerException
 An error occurred while refreshing the data from field 'SFCategoryBO.catdesc' to property 'Text' on control 'textbox1.'
BusinessLayerException
 An error occurred while refreshing property 'Text' to control 'textbox1'
IndexOutOfRangeException
 Index 9 is either negative or above rows count.

Source     : MicroFour StrataFrame Business

Stack Trace:
   at System.Data.DataView.GetElement(Int32 index)
   at System.Data.DataView.get_Item(Int32 recordIndex)
   at MicroFour.StrataFrame.Business.BusinessLayer.get_CurrentRow()
   at QuoteBOLib.SFCategoryBO.get_catdesc() in C:\SF\QuoteBOLib\QuoteBOLib\SFCategoryBO.Designer.cs:line 304
   at QuoteBOLib.SFCategoryBO.Field_catdesc_Descriptor.GetValue(Object component) in C:\SF\QuoteBOLib\QuoteBOLib\SFCategoryBO.Designer.cs:line 569
   at System.Windows.Forms.BindToObject.GetValue()
   at System.Windows.Forms.Binding.PushData(Boolean force)
   at System.Windows.Forms.Binding.ReadValue()
   at MicroFour.StrataFrame.Business.BusinessLayer.RefreshValue(Control ControlToRefresh, String PropertyName)
   at MicroFour.StrataFrame.Business.BusinessLayer.RefreshControl(IBusinessBindable ControlToRefresh, Boolean DataPresent)
   at MicroFour.StrataFrame.Business.BusinessLayer.RefreshBoundControls()
   at MicroFour.StrataFrame.Business.BusinessLayer.RaiseEditingStateChanged(EditingStateChangedEventArgs e, Boolean RefreshControls)
   at MicroFour.StrataFrame.Business.BusinessLayer.SetEditingState(BusinessEditingState EditState, Boolean RefreshControls)
   at MicroFour.StrataFrame.Business.BusinessLayer.DeleteByPrimaryKey(Object PrimaryKeyValue)
   at MicroFour.StrataFrame.Business.BusinessLayer.DeleteCurrentRow(Boolean CheckSecurity, Boolean OnlyMarkAsDeleted)
   at MicroFour.StrataFrame.Business.BusinessLayer.DeleteCurrentRow(Boolean OnlyMarkAsDeleted)
   at MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdDelete_Click(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.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 - 12/13/2005

Is the ShowDeletedRows property on the business object True or False?
By Scott - 12/13/2005

False
By StrataFrame Team - 12/13/2005

Oh, I just spotted the stack trace where it said that the Index was 9... I'm going to try to reproduce it here in a second, but right now I've got the help documenation re-building the class library help. I can't debug while it's working, so it will be a couple more minutes.
By StrataFrame Team - 12/13/2005

Fixed it... looking through the back logs of our source control, nothing changed... the logic was just a little off under certain conditions, so the index was never reduced to the new last record. Here's the DLL (follow the instructions in the Update Blog to get it installed) and the install will be rebuilt probably tomorrow.
By Scott - 12/13/2005

Works great,  Thank You.
By StrataFrame Team - 12/13/2005

No problem, you find it, I fix it Smile