Partilhar via


How to Delete Site Terms

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

To delete a site term, you must know its name. You can delete the site term in code or by using the Commerce Server Manager. You can delete site terms in your code by following the procedure outlined in this topic.

To delete a site term

  1. Create a ProfilesServiceAgent object. This agent will be used to connect to the Profiles Web service.

  2. Set the agent credentials that you want to use with the Profiles Web service by setting the Credentials property.

  3. Create a ProfileManagementContext object by passing it the ProfilesServiceAgent object that you created in step 1.

  4. Call the DeleteSiteTerm method, and specify the name of the site term you want to delete.

Example

The following code sample deletes a specific site term.

try
{
    // Connect to the Profiles Web service by using the agent.
    ProfilesServiceAgent agent = new ProfilesServiceAgent("https://localhost/ProfilesWebService/ProfilesWebService.asmx");
    agent.Credentials = CredentialCache.DefaultNetworkCredentials;
    ProfileManagementContext ctxt = ProfileManagementContext.Create(agent);

    // Delete the site term called "Locations".
    ctxt.DeleteSiteTerm("Locations");

    // Success!
    Console.WriteLine("Successfully deleted site term.");
}
catch (Exception ex)
{
    Console.WriteLine("Exception: {0}\r\nMessage: {1}", ex.GetType(), ex.Message);
    if (ex.InnerException != null)
    {
        Console.WriteLine("\r\nInner Exception: {0}\r\nMessage: {1}", ex.InnerException.GetType(), ex.InnerException.Message);
    }
}

Compiling the Code

  • To compile the code, you need to include the following namespace directive:
using Microsoft.CommerceServer.Profiles;

See Also

Other Resources

How to Use Site Terms

Site Terms Concepts and Tasks

How to Create and Update Site Terms