Wife/Girlfriend/Sister?
Pepper Spray &
Stun Gun Specials!
KEEP THEM SAFE.
 CoverYourASP --> Searching articles for hand-picked keywords, Part 4

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
18 active users
48 visitors today
174 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2012 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

Querying the database

Having created the sSQLSearch SQL statement, let's search the database and display the results.

// open database connection
DBInitConnection ( );

// use static cursor to get record count
oRecordSet.Open ( 'SELECT URL,ShortDescr FROM ArticlePages WHERE ' + sSQLSearch, oConnection, adOpenStatic );

if ( !oRecordSet.EOF )
{
   var nCount = oRecordSet.RecordCount;

   Out ( 'I found ' + nCount + ' results matching "' + sSearch + '".<p>' );

   while ( !oRecordSet.EOF )
   {
      var sURL = '' + oRecordSet ( 0 );
      var sShortDescr = '' + oRecordSet ( 1 );

      Out ( '<a href="' + sURL + '">' + sShortDescr + '</a><br>' );

      oRecordSet.moveNext ( );
   }

   // release connection asap
   DBReleaseConnection ( );
}

The DB..( ) functions and the oConnection/oRecordSet objects are all defined in my Database.asp SSI. The code above shows a typical recordset loop, where you keep calling moveNext( ) until you have looped through all the records and reach End Of File (EOF).

That's the search. The only hard part was reading all those pages again, and deciding what you guys want to search for. There is always room for improvement of course - here are some things that I have on the list:

• Allowing boolean expressions such as "(a OR b) AND (c or d)".
• Storing keywords that were searched for in database.
• Displaying common search expressions.

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems



See my source code
wherever you see this icon...

You can also download the entire site source code for FREE!


New Proposal Kit Professional 5.1
Brand yourself as a top professional: create quotes and amazing proposals and get many legal documents free!

The latter saved me 3 times the purchase price on the first day I owned it!