try { Program.connexion.Open(); SqlCommand myCommand = new SqlCommand("SELECT adress1 ,Adresse FROM adress,Oven ", Program.connexion); SqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { for (int i = 0; i < nbr_it; i++) if (reader[0].ToString() == reader[1].ToString()) { it[i].SubItems[2].Text = ("OFF"); this.it[i].SubItems[0].ForeColor = Color.Cyan; } else { it[i].SubItems[2].Text = ("ON"); this.it[i].SubItems[0].ForeColor = Color.Cyan; } } reader.Close() catch (Exception z) { MessageBox.Show(z.ToString()); } Program.connexion.Close();
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questiontry { Program.connexion.Open(); SqlCommand myCommand = new SqlCommand("SELECT adress1 ,Adresse FROM adress,Oven ", Program.connexion); SqlDataReader reader = myCommand.ExecuteReader(); int cpt = 0; while (reader.Read()) { for (int i = 0; i < nbr_it; i++) if (reader[cpt].ToString() == reader[cpt+1].ToString()) { it[i].SubItems[2].Text = ("OFF"); this.it[i].SubItems[0].ForeColor = Color.Cyan; } else { it[i].SubItems[2].Text = ("ON"); this.it[i].SubItems[0].ForeColor = Color.Cyan; } cpt++; } reader.Close() catch (Exception z) { MessageBox.Show(z.ToString()); } Program.connexion.Close();