Populate combobox using MySQL .Net connector
Posted on 2011-09-06
I need to populate combobox1 with the query "select id, name from table1" using MySQL .Net connector.
name = display value
id = value i need on combobox1 selected item
Please include ALL syntax, including db connection, on button click event.
Code below is T-SQL from an earlier project, more-or-less what i'm trying to do:
Dim cmd1 As New SqlClient.SqlCommand("select id, name from table1")
Dim adapter1 As New SqlClient.SqlDataAdapter
adapter1.SelectCommand = cmd1
Dim dSet1 As New DataSet
Dim conn1 As New SqlClient.SqlConnection("Some Connection String")
adapter1.SelectCommand.Connection = conn1
combobox1.DataSource = dSet1.Tables("table1")
combobox1.DisplayMember = "name"