Salut,
je veut afficher dans un ComboBox les nom des etudiants enregistrer dans la base de donnée
j'ai utiliser ce code mais il m'affiche n'importe quoi![]()
merci de votre 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 Private Sub AfficheEtudiant_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cnn As OleDbConnection Dim cmd As OleDbCommand Dim strcnn, strsql As String Dim i, n As Integer Dim dr As OleDbDataReader = Nothing strcnn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source= C:\Documents and Settings\Administrateur\Bureau\rapport\base.mdb;" cnn = New OleDbConnection(strcnn) strsql = "select NomEtudiant from Etudiant" cnn.Open() cmd = New OleDbCommand(strsql, cnn) cmd.Connection = cnn dr = cmd.ExecuteReader() n = dr.FieldCount() ComboBoxEtudiant.Items.Clear() For i = 0 To n - 1 Try ComboBoxEtudiant.Items.Insert(i, dr.Item(i)) Catch ex As Exception MessageBox.Show(ex.Message, "ereur", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try Next i cnn.Close() cnn = Nothing cmd = Nothing dr = Nothing End Sub![]()
Partager