The code for the routine Main, annotated for easier comprehension, is:

Sub Main()     Dim sPhrase, sCacheKey, sCatalogSetID     Dim sSearchPhrase     Dim rsSearchResults, iRecordCount     

The following constant, MIN_SEARCHRESULTS, is actually used as the starting record, not the minimum number of search results to return. If more than 50 records are returned by the search, the Retail Solution Site, as released, cannot show the matches beyond the 50th one. To do so, the page would need to be enhanced so that it could be called again with an additional query string parameter that indicates the appropriate starting record. Then, "next page" and "previous page" links could be conditionally added, and the search page could call itself with different starting record values.

    Const MIN_SEARCHRESULTS = 1     Const MAX_SEARCHRESULTS = 50          Call EnsureAccess()     sPageTitle = mscsMessageManager.GetMessage("L_Search_HTMLTitle", sLanguage)          ' Initialize     sPhrase = ""     sSearchPhrase = ""     

The keyword(s) to be searched for are passed to this page as the value of the query string parameter "keyword." The routine GetRequestString is used to retrieve the keyword(s) from the query string.

    ' Get search phrase     sPhrase = LCase(GetRequestString("keyword", Null))     If IsNull(sPhrase) Then         sSearchPhrase = ""     Else         sSearchPhrase = sPhrase     End If     

The site caches the results of keyword searches and checks it using the routine bFullTextResultsAreCached. If the same keyword has been used before, the previous results are immediately assigned to the variable htmPageContent and the routine Main is done (note that the body of the if condition is empty). If the search result for this particular search is not found in the cache, the site routine rsFreeTextSearch is called to perform the requested search. The RecordSet object resulting from the search is then passed to the routine htmRenderFullTextSearchResults for conversion to HTML and assignment to the variable htmPageContent.

    ' If results are cached, the query doesn't need to be run     If bFullTextResultsAreCached(sSearchPhrase, htmPageContent, sCacheKey) Then         '     Else         Set rsSearchResults = rsFreeTextSearch(sSearchPhrase, _                                                MIN_SEARCHRESULTS, _                                                MAX_SEARCHRESULTS, _                                                iRecordCount)         htmPageContent = htmRenderFullTextSearchResults(sSearchPhrase, _                                                         rsSearchResults, _                                                         sCacheKey, _                                                         iRecordCount)     End If     ' The result to display is now in htmPageContent. End Sub 
Previous  Next

Microsoft Corporation - Microsoft. Net Server Solutions for the Enterprise
Microsoft .NET Server Solutions for the Enterprise
ISBN: 0735615691
EAN: 2147483647
Year: 2002
Pages: 483 © 2008-2017.
If you may any questions please contact us: