Combobox不会显示重复的名称(如果存在) [英] Combobox doesnt show duplicate names (if exists)

查看:71
本文介绍了Combobox不会显示重复的名称(如果存在)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hy


我的程序中有一个组合框。



在我的数据库客户端中具有相同名称。我的组合框的dysplay成员是FirstName + LastName + MiddleName。



组合框设置为:



AutoCompletMode to:建议

AutoCompletSource to:ListItems。



当我搜索客户端名称时(客户名称的2条记录)数据库),在我的组合框中只显示数据库中的第二个客户端名称insertad。



如何显示我的客户的所有名称?



这是我的组合框组合代码:



 Program.Connection.CommandText =   SELECT LastName +','+ FirstName +''+ IIF(MiddleName,MiddleName,'')AS NumeComplet,ClientId FROM Clients GROUP BY ClientId,LastName,FirstName,MiddleName ORDER BY ClientId; 
DataTable Table = new DataTable();

Program.Connection.FillDataTable(表, true );
cboNumeClient.DataSource = Table;
cboNumeClient.DisplayMember = NumeComplet;
cboNumeClient.ValueMember = ClientId;
cboNumeClient.Focus();





不是从数据库中删除重复名称的解决方案。



如果我使用建议模式搜索客户名称,列表中会显示为同一客户名称添加的最后一条记录。



如果我使用箭头选择客户名称,则在组合框列表中显示我的所有客户端,广告当我选择一个并在另一个控件上单击外部时,组合框会自动选择第一个具有相同名称的客户端。

解决方案

不是从数据库中删除重复名称的解决方案



然后你为什么要这样做?

如果你有两行具有相同的名称而你在该名称上使用GROUP BY,你将只返回一行...

Hy
I have a combobox in my program.

In my database client with the same name. The dysplay member of my combo box is FirstName + LastName + MiddleName.

The combobox is set to:

AutoCompletMode to: Suggest
AutoCompletSource to : ListItems.

When i search a client name (2 record of the name client in the database), in my combo box appear only the second client name insertad in database.

How to show all name of my clients?

This is my code for pupulating tha combobox:

Program.Connection.CommandText = "SELECT LastName + ', ' + FirstName + ' ' + IIF(MiddleName, MiddleName,'') AS NumeComplet, ClientId FROM Clients GROUP BY ClientId, LastName, FirstName, MiddleName ORDER BY ClientId";
            DataTable Table = new DataTable();

            Program.Connection.FillDataTable(Table, true);
            cboNumeClient.DataSource = Table;
            cboNumeClient.DisplayMember = "NumeComplet";
            cboNumeClient.ValueMember = "ClientId";
            cboNumeClient.Focus();



Is not a solution to remove the duplicate names from database.

If i use the "Suggest" mode for search a client name, in the list are show the last record added for the same client name.

If i use the arrow to select a client name, in the the list of the combo box are show all my clients, ad when i select one and click outside on a another control, the combo box autoselect the first client with the same name.

解决方案

"Is not a solution to remove the duplicate names from database"

Then why are you doing just that?
If you have two rows that have identical names and you use GROUP BY on that name, you will only get one row returned...


这篇关于Combobox不会显示重复的名称(如果存在)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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