Quantcast
Viewing all articles
Browse latest Browse all 21

Search as you type implementation in C# using Sql Database

We have seen it on google, bing and other search engines that when you write a keyword or a pair of them the search box shows some related data to what you type. This can also be implemented in Sql database using C#.

To get this done we presume that there exists a database if you don’t know how to make a sql database in C# visit this page it shows you full steps of it.

Steps:

Step1: Drag and drop a textbox on C# form. Drag and drop a dataGridView on which your intellisense data will be displayed and updated accordingly.

Step2: Double click this textBox to get to coding side of textChange event.

Step3: In this event write this code


Now in this code we have used a query which is the base for this intellisense property. What this query is doing is that it is selecting from Employee table all the important attributes of all employees whose names are like what you entered in textBox up till now.

Then after this Sql data adapter gets the data in it and gives it to dataGridView that we dropped on our form. This query uses a ‘like’ keyword and its self explanatory. Given below is a figure that shows this intellisense property as user types in characters on textBox. You can see that when only ‘s’ was typed there were more results but as we typed ‘sir’ the results converged and became more exact to what we are searching for in database. To download a complete working database with intellisense click here

Image may be NSFW.
Clik here to view.


Viewing all articles
Browse latest Browse all 21

Trending Articles