简体   繁体   English

Visual Studio中的连接错误

[英]Connection error in Visual Studio

I'm developing a web application using ASP.NET. 我正在使用ASP.NET开发Web应用程序。 My database is on another server which is called DataServer . 我的数据库位于另一台称为DataServer服务器上。 The database server OS is Windows Server 2003 and it uses SQL Server 2008 R2. 数据库服务器操作系统是Windows Server 2003,它使用SQL Server 2008 R2。 The problem is that when I start my computer and run the application for the first time it can't connect to the server and shows the following error: 问题是,当我启动计算机并首次运行该应用程序时,它无法连接到服务器并显示以下错误:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. 建立与SQL Server的连接时发生与网络相关或特定于实例的错误。 The server was not found or was not accessible 服务器未找到或无法访问

I open My Computer and type \\\\DataServer on the address bar of windows explorer and browse the server files. 我打开“ My Computer然后在Windows资源管理器的地址栏上键入\\\\DataServer ,然后浏览服务器文件。 After doing this the problem disappears. 完成此操作后,问题消失了。

How can I fix it? 我该如何解决?

This may just be a name resolution problem - are you using a domain controller or is this in a workgroup? 这可能只是一个名称解析问题-您使用的是域控制器还是在工作组中? Are you on and off a VPN in order to connect to the server? 您是否打开和关闭VPN才能连接到服务器?

In any case, you can tell Visual Studio to connect to the IP address of DataServer instead of the name (either in the connection you've added to the project or the connection string explicitly specified in web.config). 无论如何,都可以告诉Visual Studio连接到DataServer的IP地址而不是名称(在添加到项目的连接中或在web.config中显式指定的连接字符串中)。 You can also add an entry to your hosts file that will supersede any DNS resolution. 您还可以在主机文件中添加一个条目,该条目将取代任何DNS解析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM