2015-04-07 107 views
0

我以前使用過IIS,但我從未使用過數據庫,也從未完成過Web應用程序。我做了將站點放到IIS上的相同步驟,除了當我進入一個具有數據庫連接的頁面時,所有工作都一樣。我已經嘗試了很多,這是我得到的。在IIS數據庫連接問題上託管ASP.NET Web應用程序

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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.

Windows應用程序事件日誌:

Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.

這個建於Visual Studio和我有一個SQL Express的數據庫。 我發佈了我的連接字符串,非常感謝任何幫助。

我已經加入這個我的applicationHost.config:

<add name="DefaultAppPool"> 
    <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" /> 

現在我得到:

An attempt to attach an auto-named database for file |MY DB1 FILE| failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\DB1.mdf;Initial Catalog=aspnet-ICCAA_VIZIER-20150223043129;Integrated Security=True" providerName="System.Data.SqlClient"/> 
<add name="ConnectionString" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\DB2.mdf;Integrated Security=True;Connect Timeout=30" providerName="System.Data.SqlClient"/> 
+0

什麼了「請參閱Windows應用程序事件日誌錯誤的詳細信息。」揭露? –

+0

無法獲取本地應用程序數據路徑。很可能用戶配置文件未加載。如果LocalDB在IIS下執行,請確保爲當前用戶啓用配置文件加載。 – Chetdu

+0

您是否嘗試過搜索錯誤? http://www.bing.com/search?q=Cannot+get+a+local+application+data+path.+Most+probably+a+user+profile+is+not+loaded.+If+LocalDB+ + IIS%2C下+執行+ + +製作+肯定是+模式+裝載 –

回答

0

我能弄明白。我將所有數據連接都更改爲。\ SqlExpress。這導致我的另一個錯誤:

Login failed for user ‘NT AUTHORITYNETWORK SERVICE‘

爲了解決這個問題,我跟着這篇文章弄明白了。

Login Failed For user NetworkService

相關問題