2011-02-18 83 views
2

我一直在試圖讓ASP.net成員ship proveider與我在SQL Azure中託管的其他數據庫一起工作。我已經針對數據庫運行了適當的SQL Azure特定腳本來進行設置。該腳本可以從微軟在這裏:http://archive.msdn.microsoft.com/KB2006191試圖將Asp.Net Memebership數據庫部署到SQL Azure

然而,每次我使用Visual Studio 10上運行我的網站在調試模式下,我得到以下錯誤:

An error occurred during the execution of the SQL file 'InstallCommon.sql'. The SQL error number is 5123 and the SqlException message is: CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file 'C:\USERS\ROBERTO\DOCUMENTS\VISUAL STUDIO 2010\PROJECTS\FLYINGSHAKESTORE\MVCMUSICSTORE\APP_DATA\ASPNETDB_TMP.MDF'. CREATE DATABASE failed. Some file names listed could not be created. Check related errors. Creating the ASPNETDB_74b63e50f61642dc8316048e24c7e499 database...

其他所有對數據庫的訪問完美的作品。所以它不是我的連接字符串。

我認爲,當第一次調用成員資格提供者時,ASP.Net會嘗試將新的Memberhship數據庫附加到SQLAzure(它不能),因爲它認爲它不存在。我不知道如何關閉這種行爲。

任何人都知道我能做什麼?

謝謝。

羅伯託

回答

2

謝謝你們。

一些實驗後,這是我想出了:

<roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider"> 
     <providers> 
      <clear/> 
      <add name="AspNetSqlRoleProvider" connectionStringName="..." type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral...."/> 
     </providers> 
    </roleManager> 
    <membership> 
     <providers> 
      <clear/> 
      <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider.... connectionStringName=""..../> 
     </providers> 
    </membership> 
    <profile> 
     <providers> 
      <clear/> 
      <add name="AspNetSqlProfileProvider" connectionStringName="" type="System.Web.Profile.SqlProfileProvider..../> 
     </providers> 
    </profile> 

這似乎很好地工作。清除然後用正確的連接字符串重新添加提供程序。

這取決於您是否針對數據庫運行了正確的SQL腳本。你可以在這裏得到他們:http://support.microsoft.com/kb/2006191

+0

這是非常重要的,你和所有的供應商......否則系統變得困惑在哪個供應商使用,你會得到認證錯誤 – 2013-06-06 18:19:07

3

它看起來像你居然還引用本地文件的App_Data/ASPNETDB_TMP.MDF而不是SQL Azure的實例 - 所以我懷疑,而你爲你的主數據的ConnectionString是正確的,那麼你也有一個ConnectionString留在本地數據庫呢?檢查web.config中的成員提供商

2

我認爲默認情況下,asp.net mebership系統使用名爲LocalSqlServer的連接字符串。在你的web.config中設置它,你應該很好。

<configuration> 
    <connectionStrings> 
     <add name="LocalSqlServer" 
     connectionString="Connectionstring..." 
     providerName="Provider..." /> 
    </connectionStrings> 
</configuration>