且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

建立与SQL Server的连接时发生与网络相关或特定于实例的错误....

更新时间:2023-02-03 08:16:05

未找到服务器或无法访问服务器。

要解决此问题,您应该

验证实例名称是否正确,并且SQL Server配置为允许远程连接。


获取您的SQl实例名称:



 SQL Server实例名称:

SQL Server Management Studio-> RegisterServers- >双击您的服务器 打开对象资源管理器 - > 正确点击 选择属性窗口 - >常规标签 - 查看ServerName(实例名称)



SQL Server管理窗口新查询代码关键字>和 执行以下

- 获取sql server实例名称

选择 @@服务器名称


i developed a database using c# and SqlServer 2008 ....

i make an exe setup and installed in another computer this time i install sqlexpress edition
i import the data file but when i run the application i got the following error..

System.Data.SqlClient.SqlException: 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)

The server was not found or was not accessible.
To solve the problem, you should
Verify that the instance name is correct and that SQL Server is configured to allow remote connections.


Get your SQl Instance Name:

SQL Server Instance Name :

In SQL Server Management Studio->RegisterServers->double click your server to open the Object Explorer -> right click to select the properties window ->General Tab - to see the ServerName (instance name)



or Open a new query in SQL Server Management window  and execute the following

-- to get the sql server instance name

select @@ServerName