elianeasmar
Well-known member
- Joined
- Oct 3, 2013
- Messages
- 76
- Programming Experience
- Beginner
Hello. Need your help in something.
I am trying to populate the fields in a table that i created in Sql into a Combobox.
Table name: Vehicule
fields : Immatric-Marque-Modele-annee-etat-compteurkm-remarque-typv
i want this in my form, so when the user wants informations about a car,he just select a field from the combobox and the result would be displayed in a list box
i managed to put the infos in the listbox:
but couldn't populate the fields in the combobox.
I need other than this method:
Any help would be appreciated.
Thank you
Best regards.
I am trying to populate the fields in a table that i created in Sql into a Combobox.
Table name: Vehicule
fields : Immatric-Marque-Modele-annee-etat-compteurkm-remarque-typv
i want this in my form, so when the user wants informations about a car,he just select a field from the combobox and the result would be displayed in a list box
i managed to put the infos in the listbox:
Dim _cn As SqlConnection Dim _cnstring As String = "Data Source=ELIANE-VAIO\SQLEXPRESS;Initial Catalog=Car;Integrated Security=True;" Private Sub btnArray_Click(sender As Object, e As EventArgs) Handles btnArray.Click ListBox1.DataSource = Nothing ListBox1.Refresh() Dim sqlstring As String = "Select Marque, Modele From Vehicule" Dim _cmd As New SqlCommand(sqlstring, _cn) _cn.Open() Dim _dr As SqlDataReader = _cmd.ExecuteReader() While _dr.Read() ListBox2.BeginUpdate() ListBox2.Items.Add(_dr.Item("Marque") & " " & _dr.Item("Modele")) ListBox2.EndUpdate() End While _dr.Close() _cn.Close() End Sub
but couldn't populate the fields in the combobox.
I need other than this method:
Me.cmbDropDown.Items.Add("marque") Me.cmbDropDown.Items.Add("modele") Me.cmbDropDown.Items.Add("annee") Me.cmbDropDown.Items.Add("etat") Me.cmbDropDown.Items.Add("compteurkm") Me.cmbDropDown.Items.Add("remarque") Me.cmbDropDown.Items.Add("typev")
Any help would be appreciated.
Thank you
Best regards.
Last edited by a moderator: