c# name i does not exist

   Error      2      The name 'i' does not exist in the current context      C:\Users\¿¿¿7\Documents\Visual Studio 2010\Projects\tabcontrolweb\tabcontrolweb\Form1.cs      50      26      tabcontrolweb
        urls =  Reader.GetValue.ToString();
private void Form1_Load(object sender, EventArgs e)
            string MyConString = "SERVER=;" +
                 "DATABASE=webboard;" +
                 "UID=aimja;" +
                 "PASSWORD=aimjawork;" +
            MySqlConnection connection = new MySqlConnection(MyConString);
            MySqlCommand command = connection.CreateCommand();
            MySqlDataReader Reader;
            command.CommandText = "SELECT  url FROM `listweb` WHERE `url` IS NOT NULL AND ( `webbordkind` = '¿¿¿¿¿¿¿¿¿¿¿¿' ) and `nourl`= 'n' order by province, amphore limit 4 ";
            Reader = command.ExecuteReader();

            string[] urls = new string[2];
            string thisrow = "";
            string sumthisrow = "";
            string urlname ;
            while (Reader.Read())
                thisrow = "";
                for (int i = 0; i < Reader.FieldCount; i++)
                    thisrow +=  Reader.GetValue(i).ToString();
                    urlname = Reader.GetValue(i).ToString();

                    urls[i] =  Reader.GetValue(i).ToString(); 

              //  System.IO.File.AppendAllText(@"C:\file.txt", thisrow + " " + Environment.NewLine);
                sumthisrow = sumthisrow + thisrow;

Open in new window

Who is Participating?
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.

teeraAuthor Commented:
in the line 27
the for loop has to be parenthesized -

 for (int i = 0; i < Reader.FieldCount; i++)
                    thisrow +=  Reader.GetValue(i).ToString();
                    urlname = Reader.GetValue(i).ToString();

                    urls =  Reader.GetValue(i).ToString();

(Ignore the "/i" - some formatting problem)
teeraAuthor Commented:
Hi arbii
if i want to known the value of url how can i see it
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.


 easy. Declare int i; before the for loop instead of declare int i in the for loop.

 int i;
 for (i = 0; i < Reader.FieldCount; i++)
                    thisrow +=  Reader.GetValue(i).ToString();
                    urlname = Reader.GetValue(i).ToString();

like this
check it
The "urls" collection will be available even after the for loop is closed. So individual values can be accessed using the index as - urls[0] etc.
Is this what you meant?
actually you declaring urls as an string array with 2 as lenght if Field.count greater than 2 means it throw this error...
for (int i = 0; i < Reader.FieldCount; i++)
                    thisrow +=  Reader.GetValue(i).ToString();
                    urlname = Reader.GetValue(i).ToString();

                    urls =  Reader.GetValue(i).ToString();

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
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

From novice to tech pro — start learning today.