Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project



Sample ASP Site Search


Sample ASP Application
Now that we have all the basics in place:

  • You've successfully installed Site Server Search - congratulations!
  • Your host server has been configured
  • You've created a catalog, in our case we've called it 'devguru'
  • Your catalog as been built
  • You've decided on a single input form for the user's query that also acts as the results page
  • You've decided on a table of results with a Next button to navigate through the results pages.

We can now bring all of the Search items together into a generic Site Search ASP sample page.

Overview
The Site Search ASP example uses a single ASP page, 'SiteSearch.ASP', to enter the user's search criteria and then output their search results.

The page displays a form, 'frmSearch', that contains a text field, 'txtCriteria', and a submit button. When the user presses the submit button, their request is fired to the same page. At this stage we use the 'url' and 'http_referer' Server Variables to see if this is a form submit. If this is the case then it's the first time they have submitted this query so we can use the value in 'txtCriteria'.

Because we use the same form to show the various results pages we need to use the Request.QueryString to work out which record number to start displaying data from (&RecordNum=x) in conjunction with the Query object's SetQueryFromURL statement.

Once we've established how this page was called we can initialize the Query and Util objects and set the corresponding Query object's values: Query, MaxRecords, SortBy and Catalog.

We are now at a stage where we can execute the Query object's CreateRecordSet function and return the search results into a standard ADO Recordset object. If the ADO Recordset object is nothing or the EOF property is True then there has been an error creating the search results. This could be due to the Query object failing to evaluate a complex query or that there are no documents that match the search criteria. In either case, we do not need to continue with generating a search results table so we can exit the FormatSearchResults VBScript function.

Now for the standard stuff: we simply loop through the Recordset creating a table row and table columns for each record found until MoveNext results in EOF being True. Once we've got to the end we can check the Recordset's Extended Properties collection to see if MoreRows is True. If it is then we can generate the More hyperlink by setting the Query object's StartHit property to the value found in objRecordSet.Properties("NextStartHit").

Running The Site Search Sample

  1. Download the zip file SiteSearchASP.zip.
     
  2. Extract SiteSearch.asp into an IIS virtual directory on the server where Site Server Search is installed. This is the only file that you will need.
     
  3. You may have to alter the source code so that it uses the correct Site Server Search catalog name - by default it uses one called 'devguru'.
    The VBScript function, FormatSearchResults, contains a constant called cCatalogueName.
 
  1 2 3 4 5 6 7 8
 
   
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information
knoxville photographer
knoxville wedding photographer