开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜