SqlPersonalizationProvider Class
Collapse the table of content
Expand the table of content

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


Initializes a new instance of the SqlPersonalizationProvider class.


Gets or sets the name of the application to store and retrieve personalization information for.(Overrides PersonalizationProvider.ApplicationName.)


Gets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs).(Inherited from ProviderBase.)


Gets the friendly name used to refer to the provider during configuration.(Inherited from ProviderBase.)


Returns a list of WebPartUserCapability objects that represent the set of known capabilities used by the Web Parts control set.(Inherited from PersonalizationProvider.)

System_CAPS_pubmethodDetermineInitialScope(WebPartManager, PersonalizationState)

Determines whether the initial personalization scope should be Shared or User scope.(Inherited from PersonalizationProvider.)


Returns a dictionary containing WebPartUserCapability instances that represent the personalization-related capabilities of the currently executing user account.(Inherited from PersonalizationProvider.)


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodFindState(PersonalizationScope, PersonalizationStateQuery, Int32, Int32, Int32)

Returns a collection containing zero or more PersonalizationStateInfo-derived objects, based on the specified scope and parameters.(Overrides PersonalizationProvider.FindState(PersonalizationScope, PersonalizationStateQuery, Int32, Int32, Int32).)

System_CAPS_pubmethodGetCountOfState(PersonalizationScope, PersonalizationStateQuery)

Returns a count of the number of rows in the underlying data store that exist for the specified scope parameter.(Overrides PersonalizationProvider.GetCountOfState(PersonalizationScope, PersonalizationStateQuery).)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitialize(String, NameValueCollection)

Implements 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).)

System_CAPS_protmethodLoadPersonalizationBlobs(WebPartManager, String, String, Byte[], Byte[])

Loads personalization data from the underlying data store, based on the specified parameters.(Overrides PersonalizationProvider.LoadPersonalizationBlobs(WebPartManager, String, String, Byte[], Byte[]).)

System_CAPS_pubmethodLoadPersonalizationState(WebPartManager, Boolean)

Loads the raw data from the underlying data store and converts that data into a PersonalizationState object.(Inherited from PersonalizationProvider.)


Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodResetPersonalizationBlob(WebPartManager, String, String)

Deletes personalization data from the underlying data store. (Overrides PersonalizationProvider.ResetPersonalizationBlob(WebPartManager, String, String).)


Resets personalization data to the underlying data store.(Inherited from PersonalizationProvider.)

System_CAPS_pubmethodResetState(PersonalizationScope, String[], String[])

Deletes personalization state information from the underlying data store, based on the specified parameters.(Overrides PersonalizationProvider.ResetState(PersonalizationScope, String[], String[]).)

System_CAPS_pubmethodResetUserState(String, DateTime)

Deletes user personalization data from the underlying data store, based on the specified parameters.(Overrides PersonalizationProvider.ResetUserState(String, DateTime).)

System_CAPS_protmethodSavePersonalizationBlob(WebPartManager, String, String, Byte[])

Saves raw personalization data to the underlying Microsoft SQL Server database.(Overrides PersonalizationProvider.SavePersonalizationBlob(WebPartManager, String, String, Byte[]).)


Saves personalization data to a data store.(Inherited from PersonalizationProvider.)


Returns 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
Available since 2.0

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

Return to top
© 2015 Microsoft