put the contents of the database to a combobox
I am using vb.net and mysql as the database.
I have created a field containing the abbreviations of words. My vb.net form provides a combobox which I want to connect to the field abbreviation. I want to configure the combobox so that when clicked, all the acronyms that exist in the database appear in 开发者_如何学Gothe combobox.
Any suggestions on how I can get started?
Something like this:
Dim conn As New SqlConnection(connString)
Dim strSQL As String = "SELECT * FROM abbreviations"
Dim da As New SqlDataAdapter(strSQL, conn)
Dim ds As New DataSet
da.Fill(ds, "abbreviations")
With ComboBox1
.DataSource = ds.Tables("abbreviations")
.DisplayMember = "abbreviation_name"
.ValueMember = "abbreviation_id"
.SelectedIndex = 0
End With
Should give you the right idea to get started.
精彩评论