如何使用列表框从Access数据库中搜索 [英] how to search from access database using listbox

查看:132
本文介绍了如何使用列表框从Access数据库中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过以下代码仅使用datagridview从Access数据库中搜索列:

I can search a column from access database using only datagridview by the following code:

string sql = "select column2 from database_1"; 
OleDbCommand vcom = new OleDbCommand(sql, vcon); 
DataSet ds = new DataSet(); 
OleDbDataAdapter da = new OleDbDataAdapter(vcom); 
da.Fill(ds, "res"); 
dataGridView1.DataSource = ds.Tables["res"]; 
da.Dispose(); 
vcom.Dispose(); 


但是,如何使用列表框或列表视图(主要是列表框)从数据库中搜索列?


But how can I search a column from a database using listbox or listview (mainly listbox)?

推荐答案

访问权限或任何数据库与任何控件都没有关系.如果要在数据库中搜索一行,请提供适当的SQL语句以及必要的值.这些值的来源与数据库无关.
Access, or any database, has nothing to do with any controls. If you want to search for a row in the database then provide the proper SQL statement with the necessary values. Where those values come from is irrelevant to the database.


这篇关于如何使用列表框从Access数据库中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆