因为我已经将mvc3/entity框架站点从localhost移到了活动服务器上,所以我收到了这个错误。通常,当我收到这个错误时,我会检查连接字符串中的数据库名称、密码和服务器是否都是正确的。我已经检查过了--它们看起来都很好。
我在数据库中的站点上有aspnet成员提供程序,它允许我登录,验证我,然后尝试将我重定向到另一个页面,然后错误就会发生-即,只要我与成员提供程序连接到数据库。
数据库与站点在同一台服务器上,当我从本地主机连接到远程服务器时,它工作得很好。
以下是完整的错误消息:
Exception message: 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="ApplicationServices" connectionString="Data Source=192.168.1.43;Initial Catalog=BlueLadder;User Id=BlueLadderAdmin;Password=Auth1991;timeout=30" />有没有什么我可以试试的?
发布于 2011-08-10 22:21:40
好吧,尽管我在web配置中使用了连接字符串,但它实际上被忽略了,应用程序仍在尝试连接到本地版本。显然,您需要通过dbContext构造函数传递连接字符串,如下所示。
public Context()
: base("ConnectionString")
{
}不管怎样,谢谢你的帮助。
发布于 2011-08-10 00:30:33
尝试删除Data Source和Initial Catalog,并将其替换为以下内容:
Server=.\SQLEXPRESS;Database=BlueLadder;我不知道您是否在使用SQLEXPRESS,所以如果您不使用SQLEXPRESS,请进行相应的修改。
发布于 2011-08-10 16:27:23
Server = 192.168.1.43/MSSQLSERVER or Server = 192.168.1.43/SQLEXPRESS
https://stackoverflow.com/questions/6999493
复制相似问题