Bonjour,
je veux alimenter un ComboBox par le contenu d'un champs (Service) d'une table SQL (Personnel).
j'ai essayé avec le code suivant mais ça ne marche pas,ma liste déroulante du ComboBox reste toujours vide !!
pouvez vous m'aider Svp:
merci infiniment
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 private void comboBox5_SelectedIndexChanged(object sender, EventArgs e) { SqlConnection SqlConn = new SqlConnection("Data Source=TIMA;Initial Catalog=HOPITAL;Integrated Security=True"); SqlCommand SqlComm = new SqlCommand("select service from personnel", SqlConn); SqlDataAdapter Sqldata = new SqlDataAdapter(SqlComm); DataSet DS = new DataSet(); Sqldata.Fill(DS); comboBox5.DataSource = DS.Tables[0]; comboBox5.DisplayMember = "service"; }
Partager