Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello Friends,

I Wanted To Make TextBox as Dynamic Search, Just I Type Some String and the relevant string Come from the Database,and I Can Select That String And It Appears in TextBox

Just Like In Google OR Even In You Tube Sites happens

So Please Help Me , It's Urgent

Thanks in Advance
Posted
Updated 15-Jul-11 2:35am
v2

It is relatively simple if you use LinQ. If you have a List of Person objects and you wish to find the people with the phrase 'an' in their name you would do something like this

C#
class Person
   {
       public string Name { get; set; }
       public int Age { get; set; }
   }

List<Person> SelectItems(List<Person> people, string searchText)
       {
           return (from person in people where person.Name.Contains(searchText) select person).ToList();
       }


If you are trying to get the results from a database, then you need to use a LIKE clause in the query like this

C#
SqlCommand cmd = new SqlCommand("SELECT Name, Age FROM People WHERE Name LIKE @SearchString", con);
                cmd.Parameters.AddWithValue("@SearchString", "%" + searchString + "%");


Hope this helps

Oops, just saw your question was about VB, but you should get the picture.

Code conversion
Convert C# to VB.NET[^]
 
Share this answer
 
v4
Comments
thatraja 15-Jul-11 22:11pm    
Good answer, 5!
Shailesha03 16-Jul-11 0:45am    
I Doesn't get the Idea .
My Question is :
I Have an Textbox and The Database which in in MsAccess.
Suppose I wanted The State name like oklahoma but When I type Just 'Okla' then The name should appear in the textbox just like we see in Google textbox .I want that same way to be happen in vb Textbox.

If There is Any other Way then please Suggest That also

Thanks
Here is the solution....it great go through it carefully.

http://www.vbdotnetheaven.com/uploadfile/mahesh/auto-complete-textbox-in-vb-net/[^]
 
Share this answer
 
v2

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