SQL Search Control for your page using asp.net :: code

Providing only keywords, this tool will write a simple search query, run it, and display your results; lightweight and easy to customize; in both control form, and standalone page

I was tired if writing SQL for doing simple queries on my databases, especially when they got loooong... so I ended up writing a program to do it for me.  Now this is in no way a complex search tool, but it does its job.  It does use 'LIKE' as I needed it to search text fields, but you can change that out if you want - this will get you started.

 

All you need to do to get it running is to provide 3 values: 

  1. Either your DB ConnectionString, or the name of that ConnectionString in your web.config
  2. The name of the table you wish to search
  3. The column names you want to compare to the search terms

And that is it.  The search is delimitted by [space], [comma], [semicolon], and [plus-sign] and each keyword must show up in at least one of the fields in order for the search to return results.

 

I provided both a standalone page that runs the search on itself, and a control version that consists of a user control that you can insert anywhere, and a search.aspx page that will show the results.  The control is very versatile. 

 

This is a good starting point if you want to expand on it.  I made a fully customized search at work starting with this with multiple dropdowns, fields and textboxes, all built on this basic architecture.  Play around with it and tell me what you think - I would even write a tutorial on how this thing works if anyone is interested.



Comments are closed