0

i just found this code it was really nice, as im just a beginner i can't solve it. when i execute the code the text inside the combobox is not my database but instead a text "System.Data.DataRowView" im really newbie in vb.net im really curious how will this work. thanks in advance :)
Private Sub FillCombo()

 Try
            Dim fillcon As New OleDbConnection(conString)
            Dim asql As String = ("SELECT ItemName FROM ItemMaster ORDER BY ItemName")
            Dim da As New OleDbDataAdapter(asql, fillcon)
            Dim ds As New DataSet
            da.Fill(ds)
            ItemNameCombo.ValueMember = "ItemName"
            ItemNameCombo.DataSource = ds.Tables(0)
            ItemNameCombo.SelectedIndex = 0
        Catch ex As Exception
            MsgBox("ERROR : " & ex.Message.ToString)
        End Try
    End Sub
2
Contributors
1
Reply
14
Views
4 Years
Discussion Span
Last Post by kRod
0

I believe you need to set the combobox properties in the proper order.

.DisplayMember = "Need to set this one too"
.ValueMember = "ItemName"
.DataSource =  ds.Tables(0)

Also how are you accessing the selecdt item/value when a combobox item is selected? the variables datatype needs to be the same as the valuemember's datatype.

Edited by kRod

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.