SqlProfileProvider クラス
アセンブリ: System.Web (system.web.dll 内)


ASP.NET プロファイルは、データベースなどのデータ ソース内にあるユーザー設定値の格納と取得に使用されます。ユーザー プロファイルには、現在の HttpContext の Profile プロパティを使用してアクセスします。プロファイルの情報とプロパティ値は、プロファイル プロバイダを使用して管理されます。
SQL Server データベースを使用している ASP.NET アプリケーションのプロファイル設定値の格納と取得を行うために、SqlProfileProvider クラスが ASP.NET によって使用されます。SqlProfileProvider を使用するには、最初に SqlProfileProvider で使用される SQL Server データベースを作成する必要があります。SqlProfileProvider で使用されるデータベースを作成するには、[drive:]\WINDOWS\Microsoft.NET\Framework\versionNumber フォルダにある aspnet_regsql.exe ツールに -Ap オプションを指定して実行します。次に、aspnet_regsql.exe 実行可能ファイルを使用するコマンド例を示します。
aspnet_regsql.exe -Ap
上の例では作成するデータベースの名前を指定していないため、既定の名前が使用されます。既定のデータベース名は Aspnetdb です。
コンピュータの構成には、ローカル コンピュータ上の SQL Server へ接続するための AspNetSqlProvider という名前の既定 SqlProfileProvider インスタンスが含まれます。プロバイダのこのインスタンスを使用することも、ASP.NET アプリケーションの Web.config ファイルで独自に指定することもできます。
![]() |
---|
プロファイル プロバイダが、統合セキュリティを使用する接続文字列を使用するように設定されている場合、ASP.NET アプリケーションのプロセス アカウントには SQL Server データベースへの接続権限が必要です。 |

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>


System.Configuration.Provider.ProviderBase
System.Configuration.SettingsProvider
System.Web.Profile.ProfileProvider
System.Web.Profile.SqlProfileProvider


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SqlProfileProvider クラスのページへのリンク