2014-11-01 80 views
0

我使用Visual Studio Express的2013年網頁,我下面這個教程:http://www.codeproject.com/Articles/791740/Using-AngularJs-ASP-NET-MVC-Web-API-and-EntityFram指定此連接來連接OT分貝:連接到數據庫在Visual Studio Express的2013的Web

<add name="MainDb" connectionString="Server=localhost; Database=SimpleTaskSystemDb; Trusted_Connection=True;" providerName="System.Data.SqlClient" /> 

但當我運行更新,數據庫我得到這個錯誤:

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)

,我也完成了其工作正常音樂商店應用和連接有不同:

<add name="MusicStoreEntities" connectionString="Data Source=|DataDirectory|MusicStore.sdf" providerName="System.Data.SqlServerCe.4.0"/> 

我嘗試了一個類似的連接字符串,但也沒有工作。

No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'. Make sure the provider is registered in the 'entityFramework' section of the application config file.

但是音樂商店app.config文件沒有引用System.Data.SqlServerCe.4.0,但我把它添加到這個應用程序反正後來我回到我原來的錯誤。

enter image description here

任何幫助將不勝感激。

+0

你正在使用哪個版本的sql server, – ProgrammingNinja 2014-11-01 15:06:24

+0

這就是我不確定的。我正在使用Express 2013 for Web的任何版本,但我無法在任何地方找到該信息。當我運行SQLMCD -L我得到這個: 服務器: ; UID:登錄ID =?; PWD:密碼=?; Trusted_Connection:使用集成安全=? * APP:AppName =?; * WSID:WorkStation ID = ?; – Anthony 2014-11-01 15:12:53

+0

請按照我的詳細回答 – ProgrammingNinja 2014-11-01 15:25:24

回答

1

這裏有一些我所描述的每一個連接字符串的全部細節

對於本地SQL Server(的buildin的SQL Server Express到Visual Studio)的樣品連接字符串。

For Sql Server instance which comes default with visual studio you can use following connection string 

<connectionStrings> 
<add name="ConnectionStringName" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=YourDatabaseName;Integrated Security=True" 
    providerName="System.Data.SqlClient" /> 

爲SQL Server已經seperately安裝如評估版等

<connectionStrings> 
    <add name="ConnectionStringName" connectionString="Data Source=YourPCName-PC\ServerInstanceName;Initial Catalog=YourDatabaseName;Integrated Security=True" 
     providerName="System.Data.SqlClient" /> 
    </connectionStrings> 

對於SQL Server,你可以使用提供者名稱,

的CompactEdition

providerName =「System.Data .SqlServerCe.4.0「

+0

謝謝,當我使用第一個字符串時,它工作,但你能解釋爲什麼使用本教程中提到的'localhost'或'./SQLexpress'不起作用?此外,因爲我的MusicStore應用程序正在與providerName =「System.Data.SqlServerCe.4.0」這是否意味着我有2個版本安裝?看到我添加的屏幕截圖.... – Anthony 2014-11-01 15:30:31

+0

Wellcome.I沒有與Visual Studio Express一起工作,所以我不能告訴你這是爲什麼這個工作。我使用Visual Studio Ultimate 2013.我也在使用SPA(Single頁面應用程序)保持聯繫plz – ProgrammingNinja 2014-11-01 15:34:10

+0

它看起來像你安裝了兩個版本或者可能是visual studio express 2013被設計用於Compact Edition和Express Edition。 – ProgrammingNinja 2014-11-01 15:36:24

相關問題