Bonjour Forum
Bonjour tout le monde
SVP Gentelman ..
J'ai vraiment besoin d'aide pour finir ce cauchemar
Dans ma Table1 j'ai 4 champs (Id de Type numerique-Pavillon de Type numerique-Name de Type Texte-Matricule de Type numerique)
Un meme numero de Pavillon dans le champ (Pavillon) possede au MAXIMUM 3 records .. ca peut etre moins .. 2 records ou 1 record ..mais ne sera jamais quatre.
Comme l'indique cette image :
Ma ComboBox1 est deja remplit par le champs (Pavillon) d'une facon : Select distinct pour ne pas repeter les memes numeros
Je veux lorsque je choisis le numero de Pavillon par ComboBox1 .. s'affichera automatiquement les cordonnees de ces 3 records dans les TextBox de 1 a 12 .. de cette facon :
Voici tout mon code .. j'ai essaye avec .. mais malheureusement s'affichera le meme records dans les 12 TextBoxs .. voici ce resultat de malheur ..
Merci beaucoup d'avance pour l'aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Imports System.Data.OleDb Public Class Form1 Public constring As String = "Provider=Microsoft.Ace.Oledb.12.0;Data Source=" & Application.StartupPath & "\DataPavillon.accdb" Public Conne As New OleDbConnection(constring) Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Conne.Open() Dim sql As String = "Select distinct Pavillon from Table1" Dim cmd As New OleDb.OleDbCommand(sql, Conne) Dim reader As OleDb.OleDbDataReader = cmd.ExecuteReader While reader.Read Dim idPavillon = reader.Item("Pavillon") ComboBox1.Items.Add(idPavillon) End While Conne.Close() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Try Conne.Open() 'Dim sql As String = "Select * from Table1 where Pavillon =" + ComboBox1.Text + "" Dim sql As String = "Select id,Pavillon,Name,Matricule from Table1 where Pavillon =" + ComboBox1.Text + "" Dim cmd As New OleDb.OleDbCommand(sql, Conne) Dim reader As OleDb.OleDbDataReader = cmd.ExecuteReader While reader.Read If reader IsNot Nothing Then TextBox1.Text = reader.Item("id") TextBox2.Text = reader.Item("Pavillon") TextBox3.Text = reader.Item("Name") TextBox4.Text = reader.Item("Matricule") TextBox5.Text = reader.Item("id") TextBox6.Text = reader.Item("Pavillon") TextBox7.Text = reader.Item("Name") TextBox8.Text = reader.Item("Matricule") TextBox9.Text = reader.Item("id") TextBox10.Text = reader.Item("Pavillon") TextBox11.Text = reader.Item("Name") TextBox12.Text = reader.Item("Matricule") End If End While Conne.Close() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub End Class
Cordialement
MADA
Partager