【发布时间】:2012-10-10 09:30:16
【问题描述】:
可能重复:
System.Data.SqlClient.SqlException A network-related or instance-specific error
我在 c# 中有 winform 应用程序,它连接到我自己的数据库,它工作正常我当前的 sql 连接字符串是:
SqlConnection con = new SqlConnection("Data Source=ITPL_PC1;Initial Catalog=Data_Project;Persist Security Info=True;user id=sa;Password=insforia");
但是当我将此 winform 带到另一台计算机时它无法正常工作.. 然后我将连接字符串更改为:
SqlConnection con = new SqlConnection("Data Source=192.168.0.28\\ITPL_PC1;Initial Catalog=Data_Project;Persist Security Info=True;user id=sa;Password=insforia");
但它不工作......
我已经更改了远程访问的sql server中的所有设置,但仍然显示错误
Sql Exception was unhandled
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)
我的连接字符串错了吗?应该是什么?
请帮帮我
【问题讨论】:
-
是的,我更改了防火墙设置
-
您是否使用 Sql Server 配置管理器启用了 TCP-IP 客户端协议?
-
是的,感谢@damien 我解决了它
标签: c# winforms sql-server-2008 connection-string