Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5 > ASP.NET 4.5 General Discussion
ASP.NET 4.5 General Discussion For ASP.NET 4.5 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4.5 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 23rd, 2014, 05:35 PM
Authorized User
Join Date: Aug 2013
Posts: 17
Thanks: 0
Thanked 1 Time in 1 Post
Default Articles/Books on creating a database driven search box in asp.net

I have created a search box using LIKE "%" + [QueryString] + "%" however this is not powerful enough cuz it only good for one word searches, lets say I have "How are you doing today" stored in my database, a search with "How doing" will return ZERO results although we have that word, also if I type "doin today" without the "g" for "doing" I get zero results....

So do you know how to create a powerful Search Box?? Thanks
Old April 23rd, 2014, 08:43 PM
Friend of Wrox
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts

A powerful search text box would need a where clause for each search term and allow for operators. This approach you would need search terms parser to tokenize the search terms into a parse tree that you could iterate through building the search SQL where clauses.

Brown + fox == where column like '%Brown%' and column like '%fox%'
Brown fox == where column like '%Brown%' or column like '%fox%'
"Brown fox" == where column like '%Brown fox%'

Another less powerful approach that would cover your scenario would be to replace all the spaces in your search term text box with a %.

example code in search button click event
 // resulting search terms would like this: %Brown%fox%jumped%over%the%couch%
 // for a text box containing: Brown fox jumped over the couch
 Search(String.Format("%{0}%",txtbxSearchTerms.Text.Replace(' ', '%')));

Last edited by mmorgan30; April 23rd, 2014 at 11:59 PM..

Similar Threads
Thread Thread Starter Forum Replies Last Post
Articles/Books on creating a database driven search box in asp.net mark_gilb BOOK: Beginning ASP.NET 4.5 : in C# and VB 2 April 23rd, 2014 05:35 PM
ASP.NET 3.5 Articles jminatel ASP.NET 3.5 Professionals 0 February 8th, 2008 09:02 PM
Creating a Database Driven Top Menu Bar with CSS Lucy CSS Cascading Style Sheets 1 March 30th, 2006 10:14 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.