Click here to Skip to main content
15,867,834 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
My database table has one column which has all the employee names and my UI contain one textbox and one listbox.

My requirement is when I will input one character into the textbox the matching names of that character from the database table should extract and listed inside the listbox.

Ex: database table : praful,sathish,gajendra,elephant

suppose I am entering a letter "a" inside the textbox then

What I want: gajendra,sathish,praful,elephant

Please suggest me how would I do that

Thanks
Prafulla
Posted
Updated 13-May-13 23:28pm
v3
Comments
Raja Soosai 14-May-13 5:16am    
Use order by in sql query
Prafulla Sahu 14-May-13 5:30am    
Thanks raja for your reply. Please have a look once again on my edited question.
Raja Soosai 14-May-13 6:11am    
Use Like and Order by in sql. you will get.
Zoltán Zörgő 14-May-13 5:21am    
What kind of alphabetical order is giving you g,s,p,e? I can imagine e,g,p,s, but not that. What is the logic in it?
Prafulla Sahu 14-May-13 5:30am    
Thanks Zoltán for your reply. Please have a look once again on my edited question.

Try:
SQL
SELECT username FROM MyTABLE WHERE userName LIKE '%a% ORDER BY userName ASC
 
Share this answer
 
OnKeyUp event of textbox you need to do following

Clear your listbox.
Get matching names from database using sql like operator (pass textbox value in your sql).
Fill your listbox with names returned from database.
 
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