AnnihilatorSupernova
Messages postés19Date d'inscriptionmercredi 8 novembre 2000StatutMembreDernière intervention14 septembre 2005
-
28 août 2005 à 15:26
Whismeril
Messages postés19027Date d'inscriptionmardi 11 mars 2003StatutContributeurDernière intervention24 avril 2024
-
19 sept. 2012 à 16:19
Bonjour !
J'aimerais savoir comment fait-on pour récupérer le résultat d'une requête SELECT. Voici mon code pour que vous comprenniez :
oleDbConnection1.Open();
OleDbCommand dbGetNomCommand = new
OleDbCommand();
dbGetNomCommand.Connection = oleDbConnection1;
dbGetNomCommand.CommandText = "SELECT Nom FROM Clients;";
OleDbDataReader dr = dbGetNomCommand.ExecuteReader();
Et je n'arrive pas à lire ce qu'il y a dans dr. Quelqu'un peut-il m'expliquer comment faire ?
Merci d'avance.
cs_coq
Messages postés6349Date d'inscriptionsamedi 1 juin 2002StatutMembreDernière intervention 2 août 2014101 28 août 2005 à 15:33
Salut,
Tu dois utiliser la méthode Read pour passer d'une ligne à la suivante.
en gros :
oleDbConnection1.Open();
OleDbCommand dbGetNomCommand = new OleDbCommand();
dbGetNomCommand.Connection = oleDbConnection1;
dbGetNomCommand.CommandText = "SELECT Nom FROM Clients;";
OleDbDataReader dr = dbGetNomCommand.ExecuteReader();
while (rd.Read())
{
string nom = dr.GetString(0);
// faire quelquechose avec le nom
}