IProfileService2::GetProfileByKey Method [C++]

Use this method to retrieve a ProfileObject object that corresponds to a specified key member name/value pair and schema type.

Definition

[C++]

HRESULT IProfileService::GetProfileByKey(BSTRbstrKeyMemberName,
  VARIANTsValue,
  BSTRbstrType,
  VARIANT_BOOLbReturnError,
  IProfileObject**ppProfileObject);

[Visual Basic]

Function GetProfileByKey(bstrKeyMemberName As String,
  sValue As Variant,
  bstrType As StringOptionalbReturnError As Boolean) As Object

Parameters

  • bstrKeyMemberName[C++]
    [in] A BSTR that contains the key member name.
  • bstrKeyMemberName[Visual Basic]
    [in] A String that contains the key member name.
  • sValue[C++]
    [in] A VARIANT that contains the key value.
  • sValue[Visual Basic]
    [in] A Variant that contains the key value.
  • bstrType[C++]
    [in] A BSTR that contains the schema type.
  • bstrType[Visual Basic]
    [in] A String that contains the schema type.
  • bReturnError[C++]
    [in, optional, defaultvalue (-1)] An optional VARIANT_BOOL.
  • bReturnError[Visual Basic]
    [in] An optional Boolean. The default value is True (-1).
  • ppProfileObject[C++]
    [out, retval] The address of a pointer to the IProfileObject interface of the returned ProfileObject object.

Return Values

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

[Visual Basic] If this method completes successfully, it returns a ProfileObject object corresponding to the specified key member/value pair and schema name.

Error Values

[C++] The Errors property stores the collection of errors encountered in the last Profiles resource operation. For more information, see IProfileService::get_Errors.

[Visual Basic] The Errors property stores the collection of errors encountered in the last Profiles resource operation. For more information, see ProfileService.Errors.

Remarks

If the optional bReturnError parameter is set to True (-1) and the specified ProfileObject object is not found, an error message, E_PS_PROFILE_NOTEXISTS, is returned instead of a ProfileObject object.

If the bReturnError parameter is set to False (0) and the specified ProfileObject object is not found, an empty ProfileObject object is returned without an error message.

Properties with the IsCached attribute set to False are not loaded by this method.

The Fields property of the returned ProfileObject object provides access to the profile properties.

Use the GetProfile method to retrieve a profile by specifying a primary key value and schema type.

Call the Initialize method before you use this ProfileService method.

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

[C++]

The ppProfileObject parameter contains valid data only if the method completes successfully.

[Visual Basic]

Example

' oProfileService is a Commerce ProfileService object
' oProfileObject is a Commerce ProfileObject object

oProfileObject = oProfileService.GetProfileByKey("user_id", _
 "{74A38551-D6D8-FFD0-12BF-0A20C90DC8D1}", "UserObject")

See Also

[C++]ProfileService Object

[C++]IProfileService::GetProfile

[C++]IProfileService::Initialize

[C++]ProfileObject Object

[C++]IProfileObject::get_Fields

[Visual Basic]ProfileService Object

[Visual Basic]ProfileService.GetProfile

[Visual Basic]ProfileService.Initialize

[Visual Basic]ProfileObject Object

[Visual Basic]ProfileObject.Fields

Copyright © 2005 Microsoft Corporation.
All rights reserved.