![](/img/trans.png)
[英]Use config file to connect in different database sql server Application in .NET
[英].net connect to SQL Server database
我已經在本地PC上設置了ASP.NET MVC。 我已經在SQL Server Management Studio中設置了一個數據庫,並在web.config
設置了連接字符串。 當我在VS2015中轉到服務器資源管理器時,可以在我的數據連接中看到該數據庫。 但是,如果啟動網站並嘗試注冊用戶,則會出現以下錯誤:
建立與SQL Server的連接時發生與網絡相關或特定於實例的錯誤。 服務器未找到或無法訪問。 驗證實例名稱正確,並且已將SQL Server配置為允許遠程連接。 (提供者:SQL網絡接口,錯誤:26-指定服務器/實例時出錯)
我知道該字符串是正確的,因為我可以在VS2015的數據連接中看到它
我的web.config
如下:
<entityFramework>
<defaultConnectionFactory
type="System.Data.Entity.Infrastructure.SqlConnectionFactory,
EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient"
type="System.Data.Entity.SqlServer.SqlProviderServices,
EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="ForexRebatesNowDBEntities"
connectionString="metadata=res://*/Models.ForexRebatesNowEntities.csdl|res://*/Models.ForexRebatesNowEntities.ssdl|res://*/Models.ForexRebatesNowEntities.msl;provider=System.Data.SqlClient;provider
connection string="data source=MSIBEEDGE;initial
catalog=ForexRebatesNowDB;persist security info=True;user
id=sa;password=********;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
這使我的生活受挫! 我不明白該應用程序如何無法寫入SQL Server
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.