的功能只是附加獨立.mdf
文件作爲數據庫確實可用快速版本的SQL Server 只有。
你應該在任何其他情況下做的是創造上的SQL Server實例的數據庫,並通過其數據庫名稱引用它 - 而不是它的.mdf文件名。
爲了創建ASP.NET成員資格和角色子系統所需的表和存儲過程,您需要對您的SQL Server實例使用aspnet_regsql
實用程序。你說沒有工作 - 如何它不起作用?你有錯誤嗎?如果是這樣的話:什麼錯誤 ??
有關如何使用它的詳細信息,請參閱MSDN docs on aspnet_regsql。要創建ASP.NET成員資格和角色子系統,使用:
aspnet_regsql -S (your server name here) -E -A mr
的-E
使用集成安全性(例如,當前的Windows登錄)連接到SQL服務器 - 用戶帳戶需要足夠的權限進行這些操作,當然!如果你需要一個特定的SQL Server用戶,那麼有兩個-U (username) -P (password)
參數來實現這一點。
一旦你擁有了這一切,你還需要配置ASP.NET成員資格和角色子系統實際使用在於用你的SQL Server上創建新的數據庫(ASPNETDB
)。默認情況下,它們使用連接到SQL Server Express實例的aspnetdb.mdf
文件。既然你已經改變了,你需要更新你的配置!見how to do this in detail on MSDN
步驟1:連接字符串添加到您的新創建的數據庫
在你web.config
或app.config
,一個有效的連接字符串添加到您的新創建的ASP。NET的會員/角色數據庫 - 是這樣的:
<configuration>
<connectionStrings>
<add name="ASPNETDB_Connection"
connectionString="Server=YourServer;database=aspnetdb;Integrated Security=SSPI;" />
</connectionStrings>
步驟2: - 添加爲新的連接字符串你在步驟1中剛剛添加的ASP.NET成員子系統和參考的有效配置;是這樣的:
<configuration>
<system.web>
<membership defaultProvider="YourProvider" userIsOnlineTimeWindow="15">
<providers>
<clear />
<add name="YourProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="ASPNETDB_Connection"
applicationName="MyApplication"
enablePasswordRetrieval="false" enablePasswordReset="true"
requiresQuestionAndAnswer="true" requiresUniqueEmail="true"
passwordFormat="Hashed" />
</providers>
</membership>
第3步:做角色子系統一樣的:
<configuration>
<system.web>
<roleManager defaultProvider="YourProvider" enabled="true" cacheRolesInCookie="true" >
<providers>
<clear />
<add name="YourProvider"
type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ASPNETDB_Connection"
applicationName="MyApplication" />
</providers>
</roleManager>
沒有理由對任何人關閉這個問題,或將標記爲刪除,除非您的智能關於結束問題的評論。讀[faq]會更聰明很多。 –
您可能需要重新安裝Visual Studio。 「修復」安裝可能就足夠了。您在系統上安裝SQL Server Express時安裝它;現在不是。你已經撒謊了,現在道歉並說實話。 –
@JohnSaunders:那個關於結束問題的聰明評論只是爲了好玩。我覺得有些人可能會發現它太基本的問題,但我有嚴重的問題.. :) – dotNETbeginner