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
| Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
remplirCombo(chargerBDD)
End Sub
Private Sub remplirCombo(dr As OleDbDataReader)
Using dr
While dr.Read()
ComboBox1.Items.Add(dr("COMPAGNIE").ToString)
End While
End Using
End Sub
Private Function chargerBDD() As OleDbDataReader
Dim Mycommand As OleDbCommand
Dim MyConnexion As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=U:\test1.accdb;Persist Security Info=False;")
Try
Using MyConnexion
MyConnexion.Open()
Mycommand = New OleDbCommand("SELECT COMPAGNIE FROM T", MyConnexion)
Return Mycommand.ExecuteReader
End Using
Catch ex As Exception
MsgBox(ex.ToString)
Return Nothing
End Try
End Function |