【发布时间】:2013-06-07 05:20:02
【问题描述】:
我有一个连接到本地数据库的连接字符串,它工作正常。
<connectionStrings>
<add name="Entities"
connectionString="metadata=res://*/RNADataModel.csdl|
res://*/RNADataModel.ssdl|
res://*/RNADataModel.msl;
provider=System.Data.SqlClient;
provider connection string="
Data Source=my-localhost;
Initial Catalog=my-db-name;
Integrated Security=True;
multipleactiveresultsets=True;
App=EntityFramework""
providerName="System.Data.EntityClient"/>
</connectionStrings>
但是我不知道如何成功连接到远程数据库。
我试图添加User ID=user; Password=pass; 也禁用了Integrated Security 但服务器无法连接。
有没有办法修复连接字符串或其他一些解决方法来连接到远程数据库?
编辑: 每次未正确指定连接字符串时,错误来自我的网络应用程序:
Server Error in '/' Application.
The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.
和
System.Data.EntityException 抛出:{"The underlying provider failed on Open."}
如果我使用 SQL Server 管理工作室,我可以看到服务器上的数据库和凭据工作正常。可能是一些防火墙配置,有什么建议吗?
【问题讨论】:
-
那么你在连接数据库时遇到了什么错误?
-
您是否已将数据库设置为接受远程连接?即,将数据库端口添加为防火墙的例外,启用 TCP 连接等?
标签: c# sql-server visual-studio-2010 entity-framework-4