CatalogManager3.Query Method (PIA)

Use this method to perform queries against product, variant, and category data in one or more catalogs.

Definition

[Visual Basic .NET]

Imports Microsoft.CommerceServer.Interop.Catalog
Imports ADODB26Lib     ‘ for _Recordset
…
Public Function Query(strPhrase As String,
  Optional strCatalogsToSearch As Object,
  Optional eClassTypeRequired As Object,
  Optional strPropertiesToReturn As Object,
  Optional strPropertyToSortOn As Object,
  Optional fSortAscending As Boolean,
  Optional lStartingRecord As Object,
  Optional lRecordsToRetrieve As Object,
  ByRef Optional plTotalRecordsInQuery As Object) As _Recordset

[C#]

using Microsoft.CommerceServer.Interop.Catalog;
…
public void Query(stringstrPhrase,
  objectstrCatalogsToSearch,
  objecteClassTypeRequired,
  objectstrPropertiesToReturn,
  objectstrPropertyToSortOn,
  boolfSortAscending,
  objectlStartingRecord,
  objectlRecordsToRetrieve,
  ref objectplTotalRecordsInQuery);

Parameters

[Visual Basic .NET]

  • strPhrase
    A String that contains the search phrase.
  • strCatalogsToSearch
    An Object that contains the catalogs to search as a comma-separated list. An empty string indicates search all catalogs.
  • eClassTypeRequired
    An Object that contains the catalog class that you want to find. Valid values are from the CatalogClassTypeEnum enumeration, and are described in the Remarks section.
  • strPropertiesToReturn
    An Object that contains the properties to return as a comma-separated list.
  • strPropertyToSortOn
    An Object that contains the property on which to sort.
  • fSortAscending
    A Boolean that specifies whether to sort in ascending or descending order. A value of True indicates that the returned recordset will be sorted in ascending order. A value of False indicates that the returned recordset will be sorted in descending order. The default value is True.
  • lStartingRecord
    An Object that contains the starting record to retrieve. This is an offset from the first record.
  • lRecordsToRetrieve
    An Object that contains the number of records to retrieve, beginning from the starting record.
  • plTotalRecordsInQuery
    An Object used to return the total number of records matching the query.

[C#]

  • strPhrase
    A string that contains the search phrase.
  • strCatalogsToSearch
    An object that contains the catalogs to search as a comma-separated list. An empty string indicates search all catalogs.
  • eClassTypeRequired
    An object that contains the catalog class desired. Valid values are from the CatalogClassTypeEnum enumeration, and are described in the Remarks section. If you do not want to specify a catalog class, set to Type.Missing.
  • strPropertiesToReturn
    An object that contains the properties to return as a comma-separated list. If a single catalog is specified, set to Type.Missing to return all properties. If multiple catalogs are specified, one or more properties must be specified.
  • strPropertyToSortOn
    An object that contains the property on which to sort. Set to Type.Missing to indicate no sort.
  • fSortAscending
    A bool that specifies whether to sort in ascending or descending order. A value of True indicates that the returned recordset will be sorted in ascending order. A value of False indicates that the returned recordset will be sorted in descending order.
  • lStartingRecord
    An object that contains the starting record to retrieve. This is an offset from the first record. If you do not want to specify a first record, set to Type.Missing.
  • lRecordsToRetrieve
    An object that contains the number of records to retrieve, beginning from the starting record. If you do not want to specify a number, set to Type.Missing.
  • plTotalRecordsInQuery
    An object used to return the total number of records matching the query. An object with the value Type.Missing can be used to indicate that the return value is not needed.

Return Values

If this method completes successfully, it returns the _Recordset interface to a Recordset object containing the search results.

Exceptions

This method may throw one of many mapped exceptions or an exception of type COMException. See Standard COM Errors for additional details.

The following table shows the custom COM errors that a COMException can wrap.

Constant Value Description
E_CAT_CATMGR_NOT_INITIALIZED

[C#] 0x889800B5

[Visual Basic .NET] &H889800B5

The CatalogManager object has not been initialized. The CatalogManager object should be initialized before calling this method.
E_CAT_INVALID_RS_POINTER

[C#] 0x889800B7

[Visual Basic .NET] &H889800B7

The recordset pointer that you specified is invalid.
E_INVALIDARG

[C#] 0x80070057

[Visual Basic .NET] &H80070057

One or more arguments are invalid
E_CAT_INVALID_RETURN_PROPS

[C#] 0x8898011D

[Visual Basic .NET] &H8898011D

The properties to return that you specified are invalid. Properties that contain a space should be enclosed in square brackets. Properties should not contain [ or ] and /* or -- in property names.
E_CAT_INVALID_SORT_PROPS

[C#] 0x8898011E

[Visual Basic .NET] &H8898011E

The properties to sort that you specified are invalid. Properties that contain a space should be enclosed in square brackets. Properties should not contain [ or ] and /* or -- in property names.
S_FALSE 1 Query failed. The recordset is now NULL.
E_CAT_MULTI_CAT_QUERY_NEEDS_PROPS

[C#] 0x8898000F

[Visual Basic .NET] &H8898000F

When performing a query against multiple catalogs, you should specify the actual properties to return.

Remarks

The returned Recordset object and the plTotalRecordsInQuery parameter contain valid data only if the method completes successfully. The Query method is used to perform arbitrary queries against product, product variant, and category data in one or more catalogs. The strPhrase parameter is very similar to the ADO RecordsetFilter property. Simple queries should follow the key-operator-value convention (for example, length < 100). Queries whose value is a String data type should enclose that value in single quotes (for example, color = 'Blue').

More sophisticated queries can be constructed by using the AND and OR operators to group multiple clauses, such as (level > 10) OR (Name = 'Bob' AND Title='CPA').

The programming rules regarding the strPropertiesToReturn parameter vary depending on whether a single catalog name is passed in the strCatalogsToSearch parameter, or whether multiple catalog names are passed. When a single catalog name is passed, the strPropertiesToReturn parameter is optional and defaults to all properties. When multiple catalog names are passed, the strPropertiesToReturn parameter is required.

The following table shows the values of the CatalogClassTypeEnum enumeration, and shows their associated names, and describes their use.

Name Value Description
cscCategoryClass 1 Requests category data.
cscProductVariantClass 2 Requests product variant data.
cscProductClass 4 Requests product data.
cscProductFamilyClass 8 Requests product family data.
cscProductFamilyForVariantsClass 16 Requests family for variant data, which means the product family of a product variant is being requested.
cscProductVariantsForFamily 32 Requests variants for family data, which means that all of the product variants for a product family are being requested.

CatalogClassTypeEnum enumeration****values can be combined in the eClassTypeRequired parameter with logical OR operators, so that specifying cscProductClass OR cscProductVariantClass will return both product and product variant data.

If no value is specified for the strPropertiesToReturn parameter the method returns all fields in the specified catalog, otherwise it returns only the fields specified in the strPropertiesToReturn parameter.

[Visual Basic .NET]

Example

'plTotalRecordsInQuery is an existing Long. 
'Examine it after the method returns to see if 
'there are more records to get.
rsQueryResults = myCatalogManager.Query("Productid='blue suede'", _
  "ShoeCatalog", cscProductClass,"Price, SKU, Size", "SKU", TRUE, _
  1, 25, plTotalRecordsInQuery)

Requirements

Namespace: Microsoft.CommerceServer.Interop.Catalog

Platforms: Windows 2000, Windows Server 2003

Assembly: cataloglib (in cataloglib.dll)

See Also

CatalogManager3 Class

CatalogManager3.FreeTextSearch

Copyright © 2005 Microsoft Corporation.
All rights reserved.