Click here to Skip to main content
15,867,911 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
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.
Posted
Updated 1-Feb-13 7:31am
v2
Comments
CHill60 1-Feb-13 6:23am    
Post the code you're using to populate the combobox
aciobanita constantin 4-Feb-13 8:40am    
This is the code to populate my 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();

the conection stings are in a separate class.
Kishor Deshpande 1-Feb-13 6:25am    
In your stored procedure, are you using distinct clause?
Can you show me some code of fetching values from DB?
ZurdoDev 1-Feb-13 8:03am    
It's possible you are removing the duplicates in SQL. You'll have to post your SQL and your C# for us to help.
Muthuraja Irullandi 1-Feb-13 10:45am    
Are you using Distinct keyword in your query?

1 solution

"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...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900