Link to home
Start Free TrialLog in
Avatar of MrTV
MrTVFlag for Thailand

asked on

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=192.168.0.78;" +
                 "DATABASE=webboard;" +
                 "UID=aimja;" +
                 "PASSWORD=aimjawork;" +
                 "charset=utf8;";
            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 ";
            connection.Open();
            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

Avatar of MrTV
MrTV
Flag of Thailand image

ASKER

in the line 27
Avatar of arbii
arbii

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)
Avatar of MrTV

ASKER

Hi arbii
if i want to known the value of url how can i see it
SOLUTION
Avatar of guvera
guvera
Flag of India 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
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
actually you declaring urls as an string array with 2 as lenght if Field.count greater than 2 means it throw this error...
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