Link to home
Start Free TrialLog in
Avatar of SmashAndGrab
SmashAndGrab

asked on

ASP.NET code error

hi,

I have an ASP.NET error and I am unsure what is causing it...  Please see.. User generated image
I am hoping someone will be able to help me.
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Please post your Customer Data code around line 161. Chances are you are trying to access a column collection that does not have the required index value.
Avatar of SmashAndGrab
SmashAndGrab

ASKER

User generated image
It will be better if you post your code, not screenshot.
Usually this error appear, if you ask element, which is not exist in your arryay, because your size array is less.
Are you sure, that your DataTable (dt) have element [0][1] ? Does exist the second column in this DataTable?
Thank you for the comment.

Here is the actual code:

        public string[] CustomerAtCompletedStage()
        {
            var sAvailable = new string[2];
            sAvailable[0] = "False";

            DataTable dt = CustomerDetails.CompletedRequestStage(_nRequestId);

            if (dt.Rows.Count > 0)
            {
                sAvailable[0] = "True";
                sAvailable[1] = dt.Rows[0][1].ToString();
            }

            return sAvailable;
        }
    }
}

Open in new window

And what about DataTable?
Does exist element dt.Rows[0][1] ? Can you see it in debugger?
I inherited this system from a programmer who has now left the company so I don't really understand any of the code! :(
SOLUTION
Avatar of Misha
Misha
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This error is in method CompleteRequestStage. Your DataTable have not the second column.
ok - is there a workaround?  i.e. something simple without changing to much of the application code?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am afraid, that it is necessary to you to understand code in CompleteRequestStage method... And find, why your dataTable has not the second column...
Is there a way of checking if it exists first?

i.e. Psudeo code:

If dt.Rows[0][0].ToString(); EXISTS then

ok

else

IGNORE
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There is no activity from author.