StrataFrame Forum

FillDataTable returning no records cause an error

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

By Ger Cannoll - 2/8/2011

I have changed a section of my code recently where I have a this.FillDataTable(loCommand);  Now , in some scenarios, this returns no records.  This has now caused an error saying currentRowIndex is out of range. I traced this to the get method in the Business Object column.

Why I am I geting this error and what do I need to do to avoid it. I realise it is something to do with zero records being returned
By Ger Cannoll - 2/8/2011

I set up a brand new project with the same Business Object and issued the same command  (this.FilldataTable(locCommand) , which returns no records, but in this project, it behaves as expected, and even though no records are returned, no error message is given.

So there maybe is  a property of the BO, or something else on the form is casuing the error ????
By Ger Cannoll - 2/8/2011

OK  Got this sorted.

I have code in the Navigated Event of the business object which uses one of the properties to fill a child table. I coded around this with an if MyBo.Count > 0 and it seems to have sorted it
By Edhy Rijo - 2/8/2011

Hi Gerarld,

Yeap, you are right, whenever you use any of the BO properties if there is no record, then it will error out, you should always check for BO.Count >0 to be on the safe side.
By Ger Cannoll - 2/8/2011

Thanks Eddie for the confirmation.

I originally had wriiten the Data Extraction bits months ago and recently changed my searching mecahanism so that no records could be returned. I had forgotten completely about the Navigated Event and was not looking there initially.