1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
//traitement des résultats.............
// Création d'une connexion SGBD
System.Data.SqlClient.SqlConnection oConnexion = new System.Data.SqlClient.SqlConnection("Data Source=local\\SQLEXPRESS;Initial Catalog=mabase;Integrated Security=True");
// Définition de la requête à exécuter
//requete de selection
System.Data.SqlClient.SqlCommand oCommand = new System.Data.SqlClient.SqlCommand("select id_client,nom_client from matable)", oConnexion);
try
{
// Ouverture de la connexion et exécution de la requête
oConnexion.Open();
System.Data.SqlClient.SqlDataReader avtiv = oCommand.ExecuteReader();
// Parcours de la liste des utilisateurs
while (avtiv.Read()) {
string id= avtiv["id_client"].ToString();
string nom = avtiv["nom_client"].ToString();
Response.Write("<input id='" + id + "' name ='choix' type='checkbox' value='" + id + "'/>" ) ;
Response.Write(nom+"<br>") ;
}
}
catch
{
Response.Write("prob de connexion");
}
oConnexion.Close(); |
Partager