affecting data into vaiables RRS feed

  • Question

  • i want to select datas from my database and then i affect thoes datas into variables , i do this but it didn't work : 

     c3.s = "select *from controle where horaire=" + actualtime;
                SqlCommand cd = new SqlCommand(c3.s, c3.cnx);
                DateTime d1 = new DateTime();
                 DateTime d2 = new DateTime();
                 bool lu = new bool();
                 bool ma = new bool();
                 bool me = new bool();
                 bool je = new bool();
                 bool ve = new bool();
                 bool sa = new bool();
                 bool di = new bool();
                 string imp = null;
                c3.dr = cd.ExecuteReader();
                while (c3.dr.Read())
                      imp = c3.dr[0].ToString();
                      lu = (bool)c3.dr[1];
                      ma = (bool)c3.dr[2];
                      me = (bool)c3.dr[3];
                      je = (bool)c3.dr[4];
                      ve = (bool)c3.dr[5];
                      sa = (bool)c3.dr[6];
                      di = (bool)c3.dr[7];
                      d1 = (DateTime)c3.dr[8];
                      d2 = (DateTime)c3.dr[9];

    can anybody help me

    Wednesday, March 19, 2014 4:32 PM


  • First off your question has nothing to do with Linq to SQL.  

    Secondly your question is rather vague but I'll venture a guess.  In you while loop you keep overlaying the previous value with a new value.  If you want to read all those values in and persist them you need a collection to hold the values.


    Lloyd Sheen

    Wednesday, March 19, 2014 5:27 PM