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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDbConnection
Dim MiAdapter As OleDbDataAdapter
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
'' con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|Datadirectory|\CASCADING.mdb"
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & CurDir() & "\DBPays.mdb"
ChargePays()
ChargeVille()
ChargeVillage()
End Sub
Private Sub ChargePays()
Dim SQL As String = "SELECT * FROM TBL_Pays"
Dim da As New OleDbDataAdapter(SQL, con)
Dim ds As New DataSet
da.Fill(ds, "LesPays")
ComboBox1.DataSource = ds.Tables("LesPays")
ComboBox1.DisplayMember = "Pays_Name"
ComboBox1.ValueMember = "Pays_ID"
End Sub
Private Sub ChargeVille()
Try
Dim SQL As String = "SELECT * FROM TBL_Ville WHERE VILLE_Numero_Pays= " & Val(ComboBox1.SelectedValue)
Dim da As New OleDbDataAdapter(SQL, con)
Dim ds As New DataSet
da.Fill(ds, "LesVILLES")
ComboBox2.DataSource = ds.Tables("LesVILLES")
ComboBox2.DisplayMember = "VILLE_Name"
ComboBox2.ValueMember = "VILLE_ID"
Catch
End Try
End Sub
Private Sub ChargeVillage()
Try
Dim SQL As String = "SELECT * FROM TBL_Village WHERE VILLAGE_Numero_VILLE= " & Val(ComboBox2.SelectedValue)
Dim da As New OleDbDataAdapter(SQL, con)
Dim ds As New DataSet
da.Fill(ds, "LesVILLAGES")
ComboBox3.DataSource = ds.Tables("LesVILLAGES")
ComboBox3.DisplayMember = "VILLAGE_Name"
ComboBox3.ValueMember = "VILLAGE_ID"
Catch
End Try
End Sub
Private Sub Combobox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
ChargeVille()
ChargeVillage()
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ComboBox2.SelectedIndexChanged
ChargeVillage()
End Sub
End Class |