ICategory3::AddRelationshipToCategory Method [C++]

Use this method to add a relationship from this category to another specified category.

Definition

[C++]

HRESULT ICategory3::AddRelationshipToCategory(BSTRstrRelatedCategoryName,
  BSTRstrRelationshipName,
  VARIANTstrRelationshipDescription,BSTRstrCatalogName);

[Visual Basic]

Sub AddRelationshipToCategory(strRelatedCategoryName As String,
  strRelationshipName As String,
  Optional strRelationshipDescription As Variant,Optional strCatalogName As String)

Parameters

  • strRelatedCategoryName[C++]
    [in] A BSTR that contains the name of the category to which a relationship is to be added.
  • strRelatedCategoryName[Visual Basic]
    A String that contains the name of the category to which a relationship is to be added.
  • strRelationshipName[C++]
    [in] A BSTR that contains a name for the relationship.
  • strRelationshipName[Visual Basic]
    A String that contains a name for the relationship.
  • strRelationshipDescription[C++]
    [in, optional] A VARIANT of sub type String that contains an optional description for the relationship.
  • strRelationshipDescription[Visual Basic]
    A Variant of sub type String that contains an optional description for the relationship.
  • strCatalogName[C++]
    [in, optional] A BSTR that contains the name of the catalog that contains the related category.
  • strCatalogName[Visual Basic]
    A String that contains the name of the catalog that contains the related category.

Return Values

[C++] This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic] None.

Error Values

[C++] This method returns S_OK (0x00000000) to indicate success and either standard or custom COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to either standard or custom COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

The following table shows the custom COM errors that this method can return.

Constant Value Constant
E_CAT_INVALID_OPERATION_FOR_ROOT_CATEGORY

[C++] 0x889800F8

[Visual Basic] &H889800F8

E_CAT_INVALID_OPERATION_FOR_ROOT_CATEGORY
E_CAT_CATALOG_DOESNT_EXIST

[C++] 0x88980002

[Visual Basic] &H88980002

E_CAT_CATALOG_DOESNT_EXIST
E_CAT_INVALID_CATALOGNAME

[C++] 0x88980063

[Visual Basic] &H88980063

E_CAT_INVALID_CATALOGNAME
E_CAT_INVALID_CATALOG_NAME_LENGTH

[C++] 0x88980042

[Visual Basic] &H88980042

E_CAT_INVALID_CATALOG_NAME_LENGTH
E_CAT_CHARACTER_NOT_ALLOWED

[C++] 0x8898003D

[Visual Basic] &H8898003D

E_CAT_CHARACTER_NOT_ALLOWED

[C++] Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic] Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

A relationship must be given a name and may optionally be given a description. The description can include information that describes the nature of the relationship between the categories (for example, an "accessory" or "add-on"). Relationships are one way, that is, if category A has a relationship to category B, that does not create a reciprocal relationship from category B to category A.

When multiple relationships are created between the same two categories, each relationship must have a unique name.

If the strCatalogName parameter is empty or not supplied, then the catalog specified in the CatalogName property of this category is assumed.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

[Visual Basic]

Example

myCategory.AddRelationshipToCategory "Apparel", "Accessory", "This would go great with that!"

See Also

[C++]Category Object

[C++]ICategory3::RemoveRelationshipToCategory

[C++]ICategory3::SetRelatedCategories

[Visual Basic]Category Object

[Visual Basic]Category.RemoveRelationshipToCategory

[Visual Basic]Category.SetRelatedCategories

Copyright © 2005 Microsoft Corporation.
All rights reserved.