This documentation is archived and is not being maintained.

SqlPersonalizationProvider Class

Implements a personalization provider that uses Microsoft SQL Server.

Namespace:  System.Web.UI.WebControls.WebParts
Assembly:  System.Web (in System.Web.dll)

public class SqlPersonalizationProvider : PersonalizationProvider

The SqlPersonalizationProvider type exposes the following members.

Public methodSqlPersonalizationProviderInitializes a new instance of the SqlPersonalizationProvider class.

Public propertyApplicationNameGets or sets the name of the application to store and retrieve personalization information for. (Overrides PersonalizationProvider.ApplicationName.)
Public propertyDescriptionGets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs). (Inherited from ProviderBase.)
Public propertyNameGets the friendly name used to refer to the provider during configuration. (Inherited from ProviderBase.)

Protected methodCreateSupportedUserCapabilitiesReturns a list of WebPartUserCapability objects that represent the set of known capabilities used by the Web Parts control set. (Inherited from PersonalizationProvider.)
Public methodDetermineInitialScopeDetermines whether the initial personalization scope should be Shared or User scope. (Inherited from PersonalizationProvider.)
Public methodDetermineUserCapabilitiesReturns a dictionary containing WebPartUserCapability instances that represent the personalization-related capabilities of the currently executing user account. (Inherited from PersonalizationProvider.)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodFindStateReturns a collection containing zero or more PersonalizationStateInfo-derived objects, based on the specified scope and parameters. (Overrides PersonalizationProvider.FindState(PersonalizationScope, PersonalizationStateQuery, Int32, Int32, Int32).)
Public methodGetCountOfStateReturns a count of the number of rows in the underlying data store that exist for the specified scope parameter. (Overrides PersonalizationProvider.GetCountOfState(PersonalizationScope, PersonalizationStateQuery).)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeImplements the initialization procedures required for a Microsoft SQL Server personalization provider. This method is not intended to be used directly from your code. (Overrides ProviderBase.Initialize(String, NameValueCollection).)
Protected methodLoadPersonalizationBlobsLoads personalization data from the underlying data store, based on the specified parameters. (Overrides PersonalizationProvider.LoadPersonalizationBlobs(WebPartManager, String, String, Byte[], Byte[]).)
Public methodLoadPersonalizationStateLoads the raw data from the underlying data store and converts that data into a PersonalizationState object. (Inherited from PersonalizationProvider.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodResetPersonalizationBlobDeletes personalization data from the underlying data store. (Overrides PersonalizationProvider.ResetPersonalizationBlob(WebPartManager, String, String).)
Public methodResetPersonalizationStateResets personalization data to the underlying data store. (Inherited from PersonalizationProvider.)
Public methodResetStateDeletes personalization state information from the underlying data store, based on the specified parameters. (Overrides PersonalizationProvider.ResetState(PersonalizationScope, String[], String[]).)
Public methodResetUserStateDeletes user personalization data from the underlying data store, based on the specified parameters. (Overrides PersonalizationProvider.ResetUserState(String, DateTime).)
Protected methodSavePersonalizationBlobSaves raw personalization data to the underlying Microsoft SQL Server database. (Overrides PersonalizationProvider.SavePersonalizationBlob(WebPartManager, String, String, Byte[]).)
Public methodSavePersonalizationStateSaves personalization data to a data store. (Inherited from PersonalizationProvider.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

This class defines the required functionality for a personalization provider using Microsoft SQL Server. A personalization provider both loads and stores personalization data on behalf of a WebPartPersonalization instance. This class implements the logic for reading from and writing to computers running SQL Server, and also implements all the abstract methods defined in PersonalizationProvider. For more information on personalization providers, see PersonalizationProvider.

The data design for using Web Parts personalization with SQL Server relies on the existence of two common SQL database tables, and their supporting stored procedures, that are shared for most SQL-based feature implementations. These tables and views are installed and uninstalled using the following scripts:

  • installpagepersonalization.sql – Installs the personalization tables, views, and related stored procedures.

  • uninstallpagepersonalization.sql – Uninstalls the personalization tables, views, and related stored procedures.

It is important to be aware that personalization will fail if your Web application does not run at the default trust level of Medium or higher (you can set custom trust levels in a Web.config file using the <trust level="" /> element). The PersonalizationAdministration and SqlPersonalizationProvider classes both check for a trust level of Low when they are initialized. If you configure your application to run at a trust level of Low, and you use the default SqlPersonalizationProvider provider to manage the personalization data for your application, the first time that the application tries to access personalization data, it will fail because an ASP.NET worker process running in Low trust does not have the permissions necessary to call into the various classes in the System.Data.SqlClient namespace.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.