如何使用C#将数据从Access数据库获取到组合框 [英] how to get data from access database into combobox using c#
本文介绍了如何使用C#将数据从Access数据库获取到组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
page_load
{
oledbconnection con =新的oledbconnection(connectionstring);
con.open();
oledbdataadaptor adp =新的oledbdataadaptor(从表名中选择列名",con);
数据集ds = new数据集();
adp.fill(ds,"tabname");
combobox1.text = ds.tables ["tabname"].itemarray [0];
}
你好
您可以通过以下步骤获取专栏:
1单击您的组合框,然后转到comboboxTask
2-选择您的数据源(访问数据库和表)
3-在Displaymember中选择要在组合框中显示的列
4运行您的应用程序
我希望这会有用
hi m not able to get data from access database into combobox when i click on it .....i juzz want to get one column in combobox...plzz help
解决方案
page_load
{
oledbconnection con =new oledbconnection(connectionstring);
con.open();
oledbdataadaptor adp=new oledbdataadaptor("select columnname from tablename",con);
dataset ds =new dataset();
adp.fill(ds,"tabname");
combobox1.text=ds.tables["tabname"].itemarray[0];
}
hello
you can get your column by this step:
1-click on your combobox and go to comboboxTask
2-choose your data source(access database and your table)
3-choose your column that your want display in combobox, in Displaymember
4-run your Application
i hope this will be useful
这篇关于如何使用C#将数据从Access数据库获取到组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文