Index out of range

I am filtering through an index
                if ((result.Title == ds.Tables[0].Rows[0].ItemArray[6].ToString()) == true)
                {
                    foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
                    {
                        //result.Title = ds.Tables[0].Rows[0].ItemArray[6].ToString();
                        result.Title = dr.ItemArray[6].ToString();
                    }
                    results.Add(result);
                }
                else
                {
                }
I can out figure out how to write my if statement  so that it doesn't show a file if is not in the database based on my query.
the app does give me the message: There is no row at position 0. but dies with this message
MoniMatthewsAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
>the app does give me the message: There is no row at position 0
that means that the ds.tables[0] has no rows.

apart from that:
if ((result.Title == ds.Tables[0].Rows[0].ItemArray[6].ToString()) == true)
should be:
if ( result.Title == ds.Tables[0].Rows[0].ItemArray[6].ToString() )
0
 
97WideGlideCommented:
if ((result.Title = ds.Tables[0].Rows[0].ItemArray[6].ToString()) == true)
0
 
MoniMatthewsAuthor Commented:
that's what i have.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
MoniMatthewsAuthor Commented:
For anyone that has this problem.
My answer was to change my if statement
if(strSql.Length == 0)
{
then code
}
0
 
MoniMatthewsAuthor Commented:
I found the answer that best fits my code.
0
 
MoniMatthewsAuthor Commented:
While I figured out how to resolve my issue before your post. Your response is correct.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.