c# - I made a datatable. But it takes every time the first column of my database/datatable. How can I take the second row/column of it? -


can me second row/column of datatable because somehow takes everytime first 1 if want second one.

 int score = 1;     private void pbbier_click(object sender, eventargs e)     {         mysqlconnection conn = new mysqlconnection("server=localhost;database=patn4lj1;uid=root;pwd=root;");          conn.open();          mysqlcommand command = conn.createcommand();         command.commandtext = "select * locaties";         mysqldatareader reader = command.executereader();          datatable dtdata = new datatable();         dtdata.load(reader);                   //lblx.text = rowx["x"].tostring();           int xpos1 = (int32)dtdata.rows[0][0]; //dit de 4de rij van de 1ste kollom.        //  lblx.text = rowx[colx].tostring();         int xpos2 = (int32)dtdata.rows[1][0];         int xpos3 = (int32)dtdata.rows[2][0];         int xpos4 = (int32)dtdata.rows[3][0];         int xpos5 = (int32)dtdata.rows[4][0];          int ypos1 = (int32)dtdata.rows[0][1];         int ypos2 = (int32)dtdata.rows[1][1];         int ypos3 = (int32)dtdata.rows[2][1];         int ypos4 = (int32)dtdata.rows[3][1];         int ypos5 = (int32)dtdata.rows[4][1];       //  datacolumn coly = dtdata.columns[1];       //  datarow rowy = dtdata.rows[4];            //  lbly.text = rowy["y"].tostring();                   // int ypos = rowy.tostring()[4];            // lbly.text = rowy[coly].tostring();          lblaantalscore.text = score++.tostring();            bool gedaan = false;          while (gedaan == false)         {                         pbbier.location = new point(xpos1, ypos1);              if (pbbier.left == xpos1 && pbbier.top == ypos1)             {                 gedaan = true; tmloop.stop();                 messagebox.show("gefeliciteerd u hebt er " + lbltijd.text + " sec on gedaan"); tmloop.start();             }               if (gedaan == true)             {                 pbbier.location = new point(xpos2, ypos2);             }          //pbbier.location = new point(xpos3, ypos3);         //pbbier.location = new point(xpos4, ypos4);         //pbbier.location = new point(xpos5, ypos5);           }        } 

**i edited can me? if click on picturebox go positions of datareader." want if click on picturebox second time has go new coordinates of datatable. can me? **

instead use:

object data = dtdata.rows[3][1]; int xpos = data.tostring()[1];  

use:

int xpos = (int32)dtdata.rows[3][0];//you know access fourth row , first column? 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -