Hello, When I display all the agents in my listBox I get the right number of agents but not the right information. I get the result from the attachment.
And here is the code of my function:
And here is the code where I call my function:
I would like some help with my problem if possible of course.
And here is the code of my function:
C#:
public static List<Utilisateur> GetTousLesAgents()
{
List<Utilisateur> ListeUsers = new List<Utilisateur>();
string query = "SELECT ADRESSEMAIL, MDP FROM utilisateur WHERE TYPE=2";
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = query;
using (MySqlDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
//Console.WriteLine(dataReader.GetValue(0) + " || " +
// dataReader.GetValue(1));
string adU = rdr.GetString("ADRESSEMAIL");
string mdpU = rdr.GetString("MDP");
Utilisateur utilisateur = new Utilisateur(adU, mdpU);
ListeUsers.Add(utilisateur);
}
}
return ListeUsers;
}
And here is the code where I call my function:
C#:
private void btnAfficherAgentsAdmin_Click(object sender, EventArgs e)
{
Fonctions.Connexion();
listBAgentsAdmin.Items.Clear();
listBAgentsAdmin.Items.AddRange(Fonctions.GetTousLesAgents().ToArray());
}
I would like some help with my problem if possible of course.