组合框显示重复的项目 [英] Combobox displaying duplicate items

查看:227
本文介绍了组合框显示重复的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我从一个SQL Server数据库绑定的组合框。我绑定从数据库中列在组合框中。问题是,我得到同样的项目表示在有几次起来。我从一个存储过程查询。让我知道如果有什么明显的,我很想念。谢谢



 公共无效BindComboBox()
{
_dsinventory =新的DataSet();
_dsinventory = dbAccess.ExecuteQuery(InventoryOutputQuery.ComboBox_Type());
cmbType.ItemSource = _dsinventory.Tables [0] .DefaultView;
cmbType.DisplayMemberPath = _dsinventory.Tables [0] .Columns [类型]的ToString();
}


解决方案

尝试不同的关键字在你选择查询

  SELECT DISTINCT COLUMNNAME形式表


I have a combo box that I am binding from a sql server database. I am binding one column from the database into the combo box. The problem is that I get the same item showing up in there several times. I am querying from a stored procedure. Let me know if there is anything obvious that I am missing. Thanks

public void BindComboBox()
{
   _dsinventory = new DataSet();
   _dsinventory = dbAccess.ExecuteQuery(InventoryOutputQuery.ComboBox_Type());
   cmbType.ItemSource = _dsinventory.Tables[0].DefaultView;
   cmbType.DisplayMemberPath = _dsinventory.Tables[0].Columns[Type].ToString();
}

解决方案

try distinct keyword in you select query

 Select distinct columnname form table

这篇关于组合框显示重复的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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