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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

97WideGlideCommented:
if ((result.Title = ds.Tables[0].Rows[0].ItemArray[6].ToString()) == true)
0
MoniMatthewsAuthor Commented:
that's what i have.
0
MoniMatthewsAuthor Commented:
For anyone that has this problem.
My answer was to change my if statement
if(strSql.Length == 0)
{
then code
}
0
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Guy Hengel [angelIII / a3]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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.