다음을 통해 공유


IProfileService2::CreateProfile Method

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

Use this method to create a ProfileObject object.

HRESULT IProfileService::CreateProfile(
  VARIANT sValue,
  BSTR bstrType,
  IProfileObject** ppProfileObject
);
Function CreateProfile(
    sValue As Variant,
    bstrType As String
) As Object

Parameters

  • sValue
    [C++]

    [in] A VARIANT that contains the primary key value for the new ProfileObject object. The variable types permitted for this variant are VT_BSTR or VT_I4.

    [Visual Basic]

    A Variant that contains the primary key value for the new ProfileObject object. The variable types permitted for this variant are String or Long.

  • bstrType
    [C++]

    [in] A BSTR that contains the schema type for the new ProfileObject object.

    [Visual Basic]

    A String that contains the schema type for the new ProfileObject object.

  • ppProfileObject
    [C++]

    [out, retval] The address of a pointer to the IProfileObject interface of the newly created ProfileObject object. The pointer is set to NULL if a ProfileObject object of the specified primary key and schema type already exists in the Profiles store.

Return Value

[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 the newly created ProfileObject object. The object is set to Nothingif a ProfileObject object of the specified primary key and schema type already exists in the Profiles store.

Error Values

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

Remarks

If the CreateProfile method fails on an aggregated profile (one that has multiple data sources), the DeleteProfile method must be called to clean up any entries in the data stores. In this case, the DeleteProfile method will produce an error that should be ignored.

The CreateProfile method verifies that a ProfileObject object with the specified attributes does not already exist in the database.

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

Use the GetProfile or GetProfileByKey method to retrieve existing ProfileObject instances from the Profiles store.

Call the Initialize method before you use this ProfileService method.

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

Example

' oProfileService is a Server ProfileService object.
' oProfileObject1 and oProfileObject2 are Commerce Server ProfileObject objects.

oProfileObject1 = oProfileService.CreateProfile _
 ("{73A4C9C1-D68D-11D0-98BF-00A0C90DC8DF}", "Address")

oProfileObject2 = oProfileService.CreateProfile _
 ("Joeuser@microsoft.com", "UserObject")

See Also

Other Resources

ProfileService Object

IProfileService2::DeleteProfile Method

IProfileService2::GetProfile Method

IProfileService2::GetProfileByKey Method

IProfileService2::Initialize Method

ProfileObject Object

IProfileObject2::get_Fields Property