Error when Filling Business Object


Author
Message
Marcia G Akins
Marcia G Akins
Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Hi All.

This is very bizarre. I am getting this error:

BusinessLayerException
  The CurrentRow for table '[dbo].[cost_types]' could not be evaluated because the CurrentRowIndex is out of range.  Business object record count: 0.  CurrentRowIndex: -1.

Source     : MicroFour StrataFrame Business

Stack Trace:
   at MicroFour.StrataFrame.Business.BusinessLayer.get_CurrentRow()
   at CI_BusinessObjects.boCost_types.get_savings_type_FK() in C:\CI_BusinessObjects\CI_BusinessObjects\boCost_types.Designer.cs:line 283
   at CI_BusinessObjects.boCost_types.GetCostTypesBySavingsType(Int32 SavingsType_FK) in C:\CI_BusinessObjects\CI_BusinessObjects\boCost_types.cs:line 56
   at StlCI_new_winforms.Cost_types.RequeryCosts() in C:\StlCI_new_winforms\StlCI_new_winforms\Cost_types.cs:line 32
   at StlCI_new_winforms.Cost_types.cboSavings_Type_SelectionChangeCommitted(Object sender, EventArgs e) in C:\StlCI_new_winforms\StlCI_new_winforms\Cost_types.cs:line 21
   at System.Windows.Forms.ComboBox.OnSelectionChangeCommitted(EventArgs e)
   at System.Windows.Forms.ComboBox.OnSelectionChangeCommittedInternal(EventArgs e)
   at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
   at System.Windows.Forms.ComboBox.WndProc(Message& m)
   at MicroFour.StrataFrame.UI.Windows.Forms.ComboBox.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)

when I try to fill my business object. The current row index SHOULD be zero because the business object has no data. However, this should not be throwing an error.

Any ideas what is wrong? Here is my code:

if (cboSavings_Type.SelectedValue != null)

{

Int32 Savings_Type_PK = Convert.ToInt32(cboSavings_Type.SelectedValue.ToString());

object[] oParms = new object[1];

oParms[0] = Savings_Type_PK;

boCost_types.GetCostTypesBySavingsType(
Convert.ToInt32(cboSavings_Type.SelectedValue.ToString()));

}

TIA

Marcia
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Have you had a look at line 56 in your GetCostTypesBySavingsType?
It is likely you are assigning a value to savings_type_FK, but as you said, your BO is empty, so there is no row available.
Marcia G Akins
Marcia G Akins
Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Ivan George Borges (2/22/2012)
Have you had a look at line 56 in your GetCostTypesBySavingsType?
It is likely you are assigning a value to savings_type_FK, but as you said, your BO is empty, so there is no row available.


This is the line:

FillDataTable("SELECT * FROM cost_types WHERE savings_type_FK = " + savings_type_FK.ToString());

A little more information for you:

When I step into this line of code, it takes me directly here in businesslayer.vb:

<Browsable(False), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public ReadOnly Property CurrentRow() As DataRow

Get

If _CurrentRowIndex = -1 Then

Throw New BusinessLayerException("The CurrentRow for table '" & Me.TableNameAndSchema & "' could not be evaluated because the CurrentRowIndex is out of range. Business object record count: " & Me.Count & ". CurrentRowIndex: " & Me._CurrentRowIndex & ".")

Else

Return _CurrentDataTable.DefaultView.Item(_CurrentRowIndex).Row

End If

End Get

End Property

 




Edited 12 Years Ago by Marcia G Akins
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
There it is, you are using savings_type_FK, which apparently is a field from your empty BO.

FillDataTable("SELECT * FROM cost_types WHERE savings_type_FK = " + savings_type_FK.ToString());

Marcia G Akins
Marcia G Akins
Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)Advanced StrataFrame User (516 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Hi Ivan.

Yep. It was a typo Blush

Thanks for your help.

Marcia
Edited 12 Years Ago by Marcia G Akins
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
You're welcome, Marcia. Cool
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search