IProduct::AddRelationshipToProduct

Ee798780.c++_off(en-US,CS.10).gifEe798780.vb_on(en-US,CS.10).gif

Use this method to add a relationship to a specified product from this product.

Definition

HRESULT IProduct::AddRelationshipToProduct(VARIANTvarRelatedProductID,BSTRstrRelationshipName,VARIANTstrRelationshipDescription);

Parameters

varRelatedProductID

[in] A VARIANT that contains the ID of the related product.

strRelationshipName

[in] A BSTR that contains the name of the relationship.

strRelationshipDescription

[in, optional] A VARIANT that optionally contains a description for the relationship.

Return Values

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

Error Values

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.

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

Constant Value Description
E_CAT_INVALID_RELATION 0x88980039 The specified relationship was invalid. For example, a product cannot be related to itself.
E_CAT_INVALID_RELATION_DESC 0x88980055 The relationship description exceeded 256 characters.
E_CAT_INVALID_RELATION_NAME 0x88980054 The relationship name exceeded 128 characters.
E_CAT_PRODUCT_DOESNT_EXIST 0x8898001E The specified product ID did not exist.
E_CAT_RELATIONSHIP_EXISTS 0x88980033 The specified relationship already existed.

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.

Remarks

The new relationship must have a name, which you specify in the strRelationshipName parameter. It may also optionally have a description, which you can specify in the strRelationshipDescription parameter.

More than one relationship may be created between the same two products, however in this case each relationship created must be given a unique name.

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

See Also

Product Object

IProduct::AddRelationshipToCategory

IProduct::RemoveRelationshipToProduct


All rights reserved.