Microsoft KB Archive/814071

= Virtual Catalog Search Is Unsuccessful When Both a Free Text and a SQL Query Are Set =

Article ID: 814071

Article Last Modified on 11/15/2007

-

APPLIES TO


 * Microsoft Commerce Server 2002 Service Pack 1

-



SYMPTOMS
The results of a query on a virtual catalog do not reflect the set price rule if both a SQLWhereClause property and a FreeTextSearchPhrase property are specified. If only the SQLWhereClause property is set or only the FreeTextSearchPhrase property is set, the returned prices have the price rule applied.



RESOLUTION
A supported hotfix is now available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next service pack that contains this hotfix.

To resolve this problem, submit a request to Microsoft Online Customer Services to obtain the hotfix. To submit an online request to obtain the hotfix, visit the following Microsoft Web site:

http://go.microsoft.com/?linkid=6294451

Note If additional issues occur or any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. To create a separate service request, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.   Date         Time   Size     File name 05-Mar-2003 20:34  602,939  Catalogcreate.sql 06-Mar-2003 21:16   95,748  Catalogsp2migration.sql



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
To install this hotfix:
 * 1) Run the HotFixSetup.exe program. This replaces the CatalogCreate.sql file. Any new catalog in any language will have the hotfix already installed.
 * 2) Open Query Analyzer, and then run the CatalogSP2Migration.sql file. The script updates the stored procedures and drops and re-creates the catalog scratch database.

Steps to Reproduce the Behavior
The following code causes the problem to occur: private void SimpleCatalogSearch {           // This allows you to search a Commerce Server Catalog using 3 filters: // 1) Category           // 2) Keywords (Free text) // 3) Price range and product status (SQL Clause)           // This also uses custom paging on a datagrid to only bring back the exact number of records per page.            // Created Waterfront Partners 08/13/02            // INPUTS: HashTable that contains the &quot;search form&quot;             // Category, keyword(s), price range and products per page to display            try            {                // Get the search options from the session.                Hashtable htSearchOpts = (Hashtable)Session[SESSION_CAT_SEARCHCRITERIA];                // Create a Catalog Search class.                CatalogSearch csSearch = new CatalogSearch( CommerceContext.Current.CatalogSystem );                // Set the catalog name.                csSearch.CatalogNames = htSearchOpts[&quot;Catalog&quot;].ToString;

// Set the category if any check against the default const. if ( htSearchOpts[&quot;Category&quot;].ToString != UI_DROPDOWNLIST_DEFAULT_VALUE ) {                   csSearch.CategoryName = htSearchOpts[&quot;Category&quot;].ToString; }               // Build the SQL string for further filtering. // Return only active products. StringBuilder sbSql = new StringBuilder; sbSql.Append( &quot;status = 'Active'&quot; ); // Now determine if you have a PRICE RANGE to search on. if ( ( htSearchOpts[&quot;P1&quot;].ToString != &quot;&quot; ) && ( htSearchOpts[&quot;P2&quot;].ToString != &quot;&quot; ) ) {                   sbSql.Append( &quot; and [cy_list_price] between &quot; ); sbSql.Append( htSearchOpts[&quot;P1&quot;].ToString ); sbSql.Append( &quot; and &quot; ); sbSql.Append(htSearchOpts[&quot;P2&quot;].ToString;               }                else if ( (htSearchOpts[&quot;P1&quot;].ToString != &quot;&quot; ) && ( htSearchOpts[&quot;P2&quot;].ToString == &quot;&quot; ) )                {                    sbSql.Append( &quot; and [cy_list_price] >= &quot; );                    sbSql.Append( htSearchOpts[&quot;P1&quot;].ToString; }               else if ( ( htSearchOpts[&quot;P1&quot;].ToString == &quot;&quot; ) && ( htSearchOpts[&quot;P2&quot;].ToString != &quot;&quot; ) ) {                   sbSql.Append( &quot; and [cy_list_price] <= &quot; ); sbSql.Append( htSearchOpts[&quot;P2&quot;].ToString;               }                // Set the SQL WHERE clause.                csSearch.SqlWhereClause = sbSql.ToString;

// Set the free text phrase (key words), if any. if ( htSearchOpts[&quot;KeyWords&quot;].ToString != &quot;*&quot; ) {                   csSearch.FreeTextSearchPhrase = htSearchOpts[&quot;KeyWords&quot;].ToString.Replace( &quot;-&quot;, &quot; and &quot; ); }               // Now set up a search options object. CatalogSearchOptions csOptions = new CatalogSearchOptions; // Properties to return csOptions.PropertiesToReturn = &quot;[ProductName], [LongDesc], [ImageSmallFileName], [ImageLargeFileName], [Manufacturer], [Product_ID], [WFP_ID], [SKU], [cy_list_price], [ProductID]&quot;; // Product class to return - no variants here csOptions.ClassTypes = CatalogClassTypes.ProductClass | CatalogClassTypes.ProductFamilyClass; // For now sort on Manufacturer, Price ascending csOptions.SortProperty = &quot;[Manufacturer], [cy_list_price]&quot;; csOptions.SortAscending = true; // Set the paging stuff. // The search has been set up to use a datagrid custom paging method. // Only return the amount of records that will fit on a page. csOptions.StartingRecord = m_iStartIndex; csOptions.RecordsToRetrieve = Convert.ToInt32( htSearchOpts[&quot;PPP&quot;] );

// Set the options into the search object. csSearch.SearchOptions = csOptions; // Set the page size. // Execute the search and BIND depending on WHERE you are coming in. // If not a post back then a first time search so set the page count // in the viewstate and in the datagrid virtual item count. DataSet daResulst; int iSearchResults = 0; daResulst = csSearch.Search(out iSearchResults); // Set the virtual item count for custom paging. dgResults.VirtualItemCount = iSearchResults; if ( iSearchResults > 0 ) {                   lblSearchResultMSG.Text = &quot;Your search has found &quot; + iSearchResults.ToString(&quot;#,#0&quot;) + &quot; product(s).&quot;; SubSequentVisit; }                else {                   NoResultsFound; }               dgResults.DataSource = daResulst.Tables[0]; // Set up the paging options for all. dgResults.PageSize = Convert.ToInt32( htSearchOpts[&quot;PPP&quot;] ); dgResults.DataBind; }           // The following errors are catalog search errors. In all cases we will report to the user // that no results have been found. catch ( ArgumentOutOfRangeException ) {               NoResultsFound; }           catch ( ArgumentNullException ) {               NoResultsFound; }           catch ( CatalogException ce) {               Logging.LogError( &quot;Catalog Exception Error - &quot; + ce.Message ); Logging.LogError( &quot;Catalog Inner Exception Error - &quot; + ce.InnerException ); NoResultsFound; }           catch ( Exception e)            { Logging.LogError( &quot;Catalog General Error - &quot; + e.Message ); NoResultsFound; }       }

Keywords: kbhotfixserver kbqfe kbbug kbfix KB814071

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.