remplir un combobox via une table mysql
bonjour,
voila j'essaie de remplir mon combobox depuis une colonne d'une tableX
voici le code:
Code:
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
| Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim conn As MySqlConnection
Dim dr As MySqlDataReader
conn = New MySqlConnection()
conn.ConnectionString = "Data Source= localhost;user id= utilisateur ;password=1234;database=dolibarr"
Try
conn.Open()
MessageBox.Show("Connection Opened Successfully")
Dim myCommand As New MySqlCommand
Dim strQuery As String
strQuery = "SELECT " & _
"llx_product.ref " & _
"FROM " & _
"llx_product"
myCommand.Connection = conn
myCommand.CommandText = strQuery
dr = myCommand.ExecuteReader()
ComboBox1.Items.Clear()
If dr.HasRows Then
While dr.Read
ComboBox1.Items.Add(dr.Item(0))
End While
Else
MessageBox.Show("No result for your Data", "Infos" )
End If
conn.Close()
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
Finally
conn.Dispose()
End Try |
mon problème c'est que a l'exécution rien ne se produit:? et j'arrive pas a trouvé l'erreur
PS: la connexion a la base marche parfaitement
et merci d'avance :D