comboboxSite.Items.Clear() Do While objReader.Read comboboxSite.Items.Add(objReader.GetString(0)) Loop
comboboxBatiment.Items.Clear() Do While objReader.Read comboboxBatiment.Items.Add(objReader.GetString(0)) Loop
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionLe problème, c'est que la combobox ne se vide pas quand je
comboboxBatiment.Items.Clear()
Par contre il n'y aurait-il pas un moyen de passer que par les id, afin d'alléger mes requêtes SQL?!
objCommand.CommandText "SELECT Building_Name FROM ITIL_Building,ITIL_Site WHERE ITIL_Site.id_Site ITIL_Building.ide_Site AND S.Site_Name ='" & comboboxSite.SelectedItem & "'"
ajouter une list de code Private listIdName As New List(Of int64) 'dans la sub où tu charges les noms des sites Try objConnexion.Open() objCommand.CommandText = "SELECT id_Site, Site_Name FROM ITIL_Site ORDER BY Site_Name" objReader = objCommand.ExecuteReader Do While objReader.Read listIdName.clear comboboxSite.Items.Add(objReader.GetString(1)) listIdName.Add(objreader.GetInt64(0)) Loop objReader.Close() objConnexion.Close() Catch ex As Exception MessageBox.Show("L'erreur suivante a été rencontrée :" & ex.Message) End Try 'dans la sub où tu choisi un site dans le combo Private Sub comboboxSite_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comboboxSite.SelectedIndexChanged comboboxBatiment.Enabled = True dim idsite as int64 idsite = listIdName(comboboxSite.SelectedIndex) objCommand.CommandText "SELECT Building_Name FROM ITIL_Building WHERE ITIL_Building.ide_Site 'idsite' AND S.Site_Name ='" & comboboxSite.SelectedItem & "'"