2013-05-28 46 views
0

我遇到了一個問題,似乎只是從哪裏冒出來,我迷路了。asp.net中的數據源連接問題

我正在使用SQL Server 2012,並且能夠使用默認連接連接到數據庫以便使用成員資格實體。

現在每當我試圖登錄或註冊我收到以下錯誤:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

進一步下跌的錯誤頁面,我看到:

SQLExpress database file auto-creation error:

The connection string specifies a local Sql Server Express instance using a database location within the application's App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:

If the application is running on either Windows 7 or Windows Server 2008R2, special configuration steps are necessary to enable automatic creation of the provider database. Additional information is available at: http://go.microsoft.com/fwlink/?LinkId=160102 . If the application's App_Data directory does not already exist, the web server account must have read and write access to the application's directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist. If the application's App_Data directory already exists, the web server account only requires read and write access to the application's App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the application's App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server account's credentials are used when creating the new database. Sql Server Express must be installed on the machine. The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.

我不是在運行SQLEXPRESS無處我webconfig是否指向sqlexpress。

這裏是連接字符串代碼的副本:

<add name="DefaultConnection" connectionString="Data Source=localhost;Initial Catalog=TheYogaDen;Integrated Security=True" providerName="System.Data.SqlClient"/> 
    <add name="TheYogaDenEntities" connectionString="metadata=res://*/App_Code.DAL.TheYogaDenModel.csdl|res://*/App_Code.DAL.TheYogaDenModel.ssdl|res://*/App_Code.DAL.TheYogaDenModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost;initial catalog=TheYogaDen;user id=YogaDBUser;[email protected]#$;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 

我能夠連接到數據庫中使用該連接的VS服務器資源管理器。但是,當我轉到ASP.net Web配置工具並嘗試測試我的提供程序時,它告訴我沒有任何配置。我運行aspnet_regsql並配置數據庫進行連接,錯誤仍然存​​在。

任何想法?

+0

請訪問以下鏈接http://blogs.msdn.com/b/sql_protocols/archive/2007/05/13/sql-network-interfaces -error-26-error-locating-server-instance-specified.aspx –

+0

我不完全確定爲什麼會發生這種情況......但我找到了一個解決方案,或者說是一個解決方法。 我去了另一個項目,我正在測試和連接工作正常。所以我複製了webconfig文件,對登錄憑證進行了一些更改。 不是最好的解決方案,但它的工作原理。 –

回答

0

轉到SQL Server配置管理器並檢查狀態,打開所有。

+0

所有正在運行...所有不需要defaultConnection的數據庫連接都正常工作。我的表使用我的實體連接正確填充。 –

+0

檢查框架,SQL Server和Visual Studio的版本,它們必須相同。將連接置於本地模式。前面提到的 –

0

檢查服務>的SQL Server(MSSQLSERVER)啓動此服務

+0

.....所有的服務都在運行。我可以使用自定義連接字符串進行連接,但不是默認連接。 –