Breyta

Deila með


SqlProfileProvider Class

Definition

Manages storage of profile information for an ASP.NET application in a SQL Server database.

public ref class SqlProfileProvider : System::Web::Profile::ProfileProvider
public class SqlProfileProvider : System.Web.Profile.ProfileProvider
type SqlProfileProvider = class
    inherit ProfileProvider
Public Class SqlProfileProvider
Inherits ProfileProvider
Inheritance

Examples

The following code example shows the Web.config file for an ASP.NET application configured to use a SqlProfileProvider.

<configuration>  
  <connectionStrings>  
    <add name="SqlServices" connectionString=  
      "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />  
  </connectionStrings>  

  <system.web>  
    <authentication mode="Forms" >  
      <forms loginUrl="login.aspx" name=".ASPXFORMSAUTH" />  
    </authentication>  
    <authorization>  
      <deny users="?" />  
    </authorization>  
    <membership defaultProvider="SqlProvider"   
      userIsOnlineTimeWindow="15">  
      <providers>  
        <clear/>  
        <add name="SqlProvider"   
          type="System.Web.Security.SqlMembershipProvider"   
          connectionStringName="SqlServices"  
          applicationName="SampleApplication"  
          enablePasswordRetrieval="true"  
          enablePasswordReset="true"  
          passwordFormat="Encrypted"  
          requiresQuestionAndAnswer="true" />  
      </providers>  
    </membership>  

    <profile defaultProvider="SqlProvider">  
      <providers>  
        <clear />  
        <add name="SqlProvider"  
          type="System.Web.Profile.SqlProfileProvider"  
          connectionStringName="SqlServices"  
          applicationName="SampleApplication"  
          description="SqlProfileProvider for SampleApplication" />  
      </providers>  

      <properties>  
        <add name="ZipCode" />  
        <add name="CityAndState" />  
      </properties>  
    </profile>  
  </system.web>  
</configuration>  

Remarks

The ASP.NET profile is used to store and retrieve user settings in a data source such as a database. The user profile is accessed using the Profile property of the current HttpContext. Profile information and property values are managed using a profile provider.

The SqlProfileProvider class is used by ASP.NET to store and retrieve profile settings for an ASP.NET application that is using a SQL Server database. To use a SqlProfileProvider, you must first create the SQL Server database used by the SqlProfileProvider. To create the database used by the SqlProfileProvider, run the aspnet_regsql.exe tool, which is found in the [drive:]\WINDOWS\Microsoft.NET\Framework\2.0versionNumber folder, and specify the -A p option. The following command demonstrates how you might use the aspnet_regsql.exe executable:

aspnet_regsql.exe -A p  

The example above does not specify a name for the database that is created, so the default name will be used. The default database name is Aspnetdb.

The machine configuration contains a default SqlProfileProvider instance named AspNetSqlProvider that connects to the SQL Server on the local machine. You can use this instance of the provider, or specify your own in the Web.config file for your ASP.NET application.

Note

If the profile provider is configured with a connection string that uses integrated security, the process account of the ASP.NET application must have rights to connect to the SQL Server database.

Constructors

SqlProfileProvider()

Creates an instance of the SqlProfileProvider class.

Properties

ApplicationName

Gets or sets the name of the application for which to store and retrieve profile information.

Description

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

(Inherited from ProviderBase)
Name

Gets the friendly name used to refer to the provider during configuration.

(Inherited from ProviderBase)

Methods

DeleteInactiveProfiles(ProfileAuthenticationOption, DateTime)

Deletes user profile data for profiles in which the last activity date occurred before the specified date and time.

DeleteProfiles(ProfileInfoCollection)

Deletes profile properties and information for the supplied list of profiles from the data source.

DeleteProfiles(String[])

Deletes profile properties and information from the data source for the supplied list of user names.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FindInactiveProfilesByUserName(ProfileAuthenticationOption, String, DateTime, Int32, Int32, Int32)

Retrieves profile information for profiles in which the last activity date occurred on or before the specified date and time and the user name for the profile matches the specified name.

FindProfilesByUserName(ProfileAuthenticationOption, String, Int32, Int32, Int32)

Retrieves profile information for profiles in which the user name matches the specified name.

GetAllInactiveProfiles(ProfileAuthenticationOption, DateTime, Int32, Int32, Int32)

Retrieves user profile data for profiles in which the last activity date occurred on or before the specified date and time.

GetAllProfiles(ProfileAuthenticationOption, Int32, Int32, Int32)

Retrieves user profile data for profiles in the data source.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetNumberOfInactiveProfiles(ProfileAuthenticationOption, DateTime)

Gets the number of profiles in the data source where the last activity date occurred on or before the specified userInactiveSinceDate.

GetPropertyValues(SettingsContext, SettingsPropertyCollection)

Retrieves profile property information and values from a SQL Server profile database.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
Initialize(String, NameValueCollection)

Initializes the SQL Server profile provider with the property values specified in the ASP.NET application's configuration file. This method is not intended to be used directly from your code.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SetPropertyValues(SettingsContext, SettingsPropertyValueCollection)

Updates the SQL Server profile database with the specified property values.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also