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
| Private Sub comboBox_fac_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox_fac.SelectedIndexChanged
'Lorsque l'on clique sur une faculté, alors on charge les départements coreespondants
ComboBox_Dep.Items.Clear()
ComboBox_Dep.Text = ""
'on crée une connexion
Dim MyConnexion As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data source='" & Form_choix_bdd.emplacement.Text & "'")
Dim Mycommand1 As OleDbCommand = MyConnexion.CreateCommand()
Mycommand1.CommandText = "SELECT nomDep FROM Departement INNER JOIN Faculte ON Faculte.idFac = Departement.idFac WHERE Faculte.nomFac='" & ComboBox_fac.Text & "';"
MyConnexion.Open()
Dim myReader1 As OleDbDataReader = Mycommand1.ExecuteReader()
Do While myReader1.Read()
ComboBox_Dep.Items.Add(myReader1.GetString(0))
Loop
myReader1.Close()
MyConnexion.Close()
End Sub |