ProfileService.GetProfileByKey Method (PIA)

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

Definition

[Visual Basic .NET]

Imports Microsoft.CommerceServer.Interop.Profiles
…
Public Function GetProfileByKey(bstrKeyMemberName As String,
  sValue As Object,
  bstrType As StringOptionalbReturnError As Boolean) As IProfileObject

[C#]

using Microsoft.CommerceServer.Interop.Profiles;
…
public IProfileObject GetProfileByKey(stringbstrKeyMemberName,
  objectsValue,
  stringbstrType,
  boolbReturnError);

Parameters

[Visual Basic .NET]

  • bstrKeyMemberName
    A String that contains the key member name.
  • sValue
    An Object that contains the key value. The variable types permitted for this object are String or Integer.
  • bstrType
    A String that contains the schema type.
  • bReturnError
    An optional Boolean. The default value is True.

[C#]

  • bstrKeyMemberName
    A string that contains the key member name.
  • sValue
    An object that contains the key value. The variable types permitted for this object are string or int.
  • bstrType
    A string that contains the schema type.
  • bReturnError
    See Remarks for a description of this parameter.

Return Values

[Visual Basic .NET] If this method completes successfully, it returns an object that implements the IProfileObject interface corresponding to the specified key member/value pair and schema name.

[C#] This method returns an object that implements the IProfileObject interface.

Exceptions

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

The Errors property stores the collection of errors encountered in the last Profiles resource operation if an exception is thrown. For more information, see ProfileService.Errors.

Remarks

If the bReturnError parameter is set to true and the specified ProfileObject object is not found, the method throws a COMException with a value of E_PS_PROFILE_NOTEXISTS instead of returning an object reference.

If the bReturnError parameter is set to false and the specified ProfileObject object is not found, an empty ProfileObject object is returned.

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.

[Visual Basic .NET]

Example

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

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

Requirements

Namespace: Microsoft.CommerceServer.Interop.Profiles

Platforms: Windows 2000, Windows Server 2003

Assembly: mscsupslib (in mscsupslib.dll)

See Also

ProfileService Class

ProfileService.GetProfile

ProfileService.Initialize

ProfileObject Class

ProfileObject.Fields

Copyright © 2005 Microsoft Corporation.
All rights reserved.