SqlProfileProvider 類別

定義

在 SQL Server 資料庫中,管理 ASP.NET 應用程式設定檔資訊的存放。

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
繼承

範例

下列程式碼範例顯示設定為使用 SqlProfileProvider 之 ASP.NET 應用程式的Web.config檔案。

<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>  

備註

ASP.NET 設定檔可用來儲存和擷取資料來源中的使用者設定,例如資料庫。 使用者設定檔是使用 Profile 目前 HttpContext 的 屬性來存取。 設定檔資訊和屬性值是使用設定檔提供者來管理。

類別 SqlProfileProvider 是由 ASP.NET 用來儲存及擷取使用SQL Server資料庫之 ASP.NET 應用程式的設定檔設定。 若要使用 SqlProfileProvider ,您必須先建立 所使用的 SqlProfileProvider SQL Server資料庫。 若要建立 所使用的 SqlProfileProvider 資料庫,請執行 [drive:]\WINDOWS\Microsoft.NET\Framework \ 2.0versionNumber 資料夾中找到的 aspnet_regsql.exe 工具,並指定 -A p 選項。 下列命令示範如何使用 aspnet_regsql.exe 可執行檔:

aspnet_regsql.exe -A p  

上述範例不會指定所建立之資料庫的名稱,因此會使用預設名稱。 預設資料庫名稱為 Aspnetdb。

電腦群組態包含名為 AspNetSqlProvider 的預設 SqlProfileProvider 實例,可連線到本機電腦上的SQL Server。 您可以使用這個提供者實例,或在 ASP.NET 應用程式的Web.config檔案中指定您自己的實例。

注意

如果設定檔提供者已使用使用整合式安全性的連接字串進行設定,則 ASP.NET 應用程式的進程帳戶必須具有連線至SQL Server資料庫的許可權。

建構函式

SqlProfileProvider()

建立 SqlProfileProvider 類別的執行個體。

屬性

ApplicationName

取得或設定應用程式的名稱,以儲存及擷取設定檔資訊。

Description

取得簡短、易讀的描述,適合顯示在管理工具或其他使用者介面 (UI) 中。

(繼承來源 ProviderBase)
Name

取得用來在設定期間代表提供者的易記名稱。

(繼承來源 ProviderBase)

方法

DeleteInactiveProfiles(ProfileAuthenticationOption, DateTime)

刪除設定檔的使用者設定檔資料,其中設定檔的上次活動日期是發生在指定的日期和時間之前。

DeleteProfiles(ProfileInfoCollection)

從資料來源刪除提供的設定檔清單之設定檔屬性和資訊。

DeleteProfiles(String[])

從資料來源刪除提供的使用者名稱清單之設定檔屬性和資訊。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
FindInactiveProfilesByUserName(ProfileAuthenticationOption, String, DateTime, Int32, Int32, Int32)

擷取上次活動日期發生在指定日期和時間或之前,而且設定檔使用者名稱符合指定名稱的設定檔之設定檔資訊。

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

擷取使用者名稱符合指定名稱的設定檔之設定檔資訊。

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

擷取設定檔的使用者設定檔資料,其中設定檔的上次活動日期是發生在指定的日期和時間或之前。

GetAllProfiles(ProfileAuthenticationOption, Int32, Int32, Int32)

擷取資料來源中設定檔的使用者設定檔資料。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetNumberOfInactiveProfiles(ProfileAuthenticationOption, DateTime)

取得資料來源中上次活動日期發生在指定的 userInactiveSinceDate 當天或之前的設定檔數目。

GetPropertyValues(SettingsContext, SettingsPropertyCollection)

從 SQL Server 設定檔資料庫擷取設定檔屬性資訊和值。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
Initialize(String, NameValueCollection)

使用 ASP.NET 應用程式的組態檔所指定的屬性值,初始化 SQL Server 設定檔提供者。 這個方法不能從程式碼直接使用。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
SetPropertyValues(SettingsContext, SettingsPropertyValueCollection)

使用指定的屬性值更新 SQL Server 設定檔資料庫。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱