You must Sign In to post a response.
  • Category: ASP.NET

    Index was outside the bounds of the array

    The forum thread has not been reviewed by Editors yet. Readers are advised to use their best judgement before accessing this thread.
    This thread will be reviewed shortly.
    If you think this thread contain inappropriate content, please report to webmaster.
    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
  • #36109
    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
    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
    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


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.