实体框架4.1连接到外部数据库失败
我想连接到外部数据库。 我在添加连接字符串时检查了连接,没关系。 但是,当我运行该程序时,它说“登录失败,我的帐户”。实体框架4.1连接到外部数据库失败
任何人都知道发生了什么?
谢谢!
编辑,连接字符串:
connectionString="Data Source=server_of_th_db;Initial Catalog=the_DB;Integrated Security=SSPI;"
可能,你不希望使用Integrated Security=SSPI;
,这意味着当前的Windows帐户凭据用于验证。
您可能必须指定User Id
和Password
才能够连接到远程服务器。像:
connectionString="Data Source=server_of_th_db;Initial Catalog=the_DB;Uid=MY_USER_ID;Pwd=MY_PASSWORD;"
你必须从该服务器的dba获得这些凭据。
更新: 另一个可能的问题是您使用错误的.config文件。如果解决方案中有多个项目,请确保启动项目的connectionstrings
部分已正确设置。
我试过上面的代码,但是错误依然存在。我想使用SQL身份验证,但返回的错误说我的Windows帐户登录失败 – user1484319 2012-08-15 06:31:43
@ user1484319看到我的更新 – Kamyar 2012-12-23 13:56:54
您是否检查了提供的凭证,并粘贴了异常信息。 – Freeman 2012-08-14 06:37:22
我们需要更多的细节:您可以使用DBMS(即Sql Server Management Studio)连接到数据库吗? – Shai 2012-08-14 06:37:54
@Shai是的,我可以使用DQL Server Management Studio连接到该数据库 – user1484319 2012-08-14 06:41:23