如何使用组合框从数据库中检索数据? [英] how to retrieve data from database using the combo box?
本文介绍了如何使用组合框从数据库中检索数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,代码为project.sorry,这是我的新问题,我的问题是如何使用组合框从数据库中检索数据?,请给出简单的方法来完成此操作.感谢预先的代码project.
hello , code project.sorry im new at this,my question is how to retrieve data from database using the combo box?,, please give the easy way to do this thing.thanks in advance code project.
推荐答案
hai,
试试这个
hai,
try this
Try
strSql = "select col1,cl2 from table1"
''execute sql and save it in tbk1 datatabel
tbl1 = objDb.getTable(strSql)
''add default select column
dim drw as datarow
drw = tbl1.NewRow
drw.Item("col1") = "Select"
tbl1.Rows.Add(drw)
combo1.DataSource = tbl1
combo1.DisplayMember = tbl1.Columns(0).Caption
combo1.ValueMember = tbl1.Columns(1).Caption
combo1.SelectedIndex = -1
combo1.Text = "Select"
然后
then
<pre lang="sql">
dim strSql as string =select * from table 2
where
''some condition
If combo1.Text.ToLower.Trim <> "select" Then
strSql &= and table2.column= combo1.SelectedValue
End If
</pre>
这篇关于如何使用组合框从数据库中检索数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文