Forums » .NET » ASP.NET »

Index was outside the bounds of the array


Posted Date: 08 Dec 2005      Posted By:: Nellaikumar     Member Level: Gold    Member Rank: 1080     Points: 2   Responses: 3



Hi,
I am facing the following error frequently. Give me a solution.
----------------------------------------------------------------------------------------------------------------
Index was outside the bounds of the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error:


Line 115: '''''execute query
Line 116: ''''conn.Close()
Line 117: result(ii, n) = gr(n)
Line 118: n = n + 1
Line 119: Next


Stack Trace:


[IndexOutOfRangeException: Index was outside the bounds of the array.]
resource_check.Page_Load(Object sender, EventArgs e) in D:\application\resource_check.aspx.vb:117
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

------------------------------------------------------------------------------------------------------------------
Thanks in advance,
P.Nellaikumar




Responses

#36109    Author: Pavan Kumar Komaragiri      Member Level: Bronze      Member Rank: 0     Date: 08/Dec/2005   Rating: 2 out of 52 out of 5     Points: 2

You are index value grater then the array you have declared

suppose you have declared
Dim gr(10)

but the loop is going beyond 10


 
#36110    Author: Pavan Kumar Komaragiri      Member Level: Bronze      Member Rank: 0     Date: 08/Dec/2005   Rating: 2 out of 52 out of 5     Points: 2

This error will occur when index value grater then the array you have declared

suppose you have declared
Dim gr(10)

but the loop is going beyond 10


 
#36111    Author: Sandip Naskar      Member Level: Gold      Member Rank: 0     Date: 08/Dec/2005   Rating: 2 out of 52 out of 5     Points: 2

Hi,

The error you described is very generic and not related to ASP.NET only.

This happens due to the fact that result or gr array values are over flowing the array dimension.

So, check the dimention of both the arrays and debug the line where you assign value to arrays.

Hope this information helps you,

Thank you,
Sandip





 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Previous : Validation Controls
Return to Discussion Forum
Post New Message
Category: ASP.NET

Subscribe to Subscribers
Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India