This is a migrated thread and some comments may be shown as answers.

Index out of Range for Field returned from Stored Procedure

3 Answers 108 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pete
Top achievements
Rank 1
Pete asked on 27 May 2009, 11:13 AM
Hi, I've got a sqldataadapter that retrieves a field from a stored procedure for a given report parameter and populates a textbox with this value that works fine, but if I enter a value in the report parameter that hasn't got a row in the database and returns 0 rows in the stored procedure I get the error "An error has occured while processing textbox "Textbox1", index was out of range, must be non negative and less than the size of the collection."

Is there a way of checking for returned rows in the expression, and if empty put in a default value.

Thanks a lot.

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 28 May 2009, 03:44 PM
Hi Pete,

There must be something else that you're doing that would cause this error e.g. trying to access textbox in report? I believe this is the case, as I've tried to replicate this with the project I've sent you in previous thread "Parameters in Sub Reports" by changing the following line:

this.sqlDataAdapter1.SelectCommand.Parameters["@ManagerID"].Value = 0; i.e. no records are coming through.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Pete
Top achievements
Rank 1
answered on 08 Jun 2009, 10:48 AM
Hi Steve, I've got this error again, and where I enter 2 report parameters that return the detail rows, if no rows are returned I am indeed trying to put that value into the textbox value in the report, is there a way of checking this and if its an empty row populate textbox value with "No rows available" or something similar ?
0
Steve
Telerik team
answered on 12 Jun 2009, 06:20 AM
Hello Pete,

Although I was not able to get the error you describe, a possible approach for showing "No rows available" message is explained in this forum thread. We already have this feature logged for out of the box availability.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Pete
Top achievements
Rank 1
Answers by
Steve
Telerik team
Pete
Top achievements
Rank 1
Share this question
or