Here is my code first and then ill explain what im doing.

ds.Dispose();
             ds = new DataSet();
             db = new DBconnect();
             Co = new Cards('S', Global.GlobalCompanyID).SetSql();
             ds = db.GetDataSet(Co);
             dt = ds.Tables[0];
             dr = dt.Rows[0];


             Out = dr[1].ToString();
                

             if (Out != "")
             {

                 Time tm = new Time("");
                    
                   // For each row, print the values of each column.
                 foreach(DataRow row in dt.Rows)
                 {
                        
                     Out = dr[1].ToString();
                        
                        
                            
                         In = dr[0].ToString();
                  }
              }

Im trying to get time in (IN) and time out (OUT) from my Database.
the problem is when it loops through it pulls the same record again and again.
If there are three records it would pull. it pulls the first one three times.
I need it to pull the proper records.

You have to bind to a different variable in the foreach loop, like:

 foreach(DataRow row in dt.Rows)
 {

     Out = row[1].ToString();
     In =  row[0].ToString();
  }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.