【问题标题】:cannot connect sql server 2008 from another computer [duplicate]无法从另一台计算机连接 sql server 2008 [重复]
【发布时间】: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


【解决方案1】:
Data Source=ITPL_PC1

标识一个名为ITPL_PC1服务器。您正在连接到此服务器上的默认实例。

Data Source=192.168.0.28\ITPL_PC1

标识在 IP 地址为 192.168.0.28 的服务器上运行的名为 ITPL_PC1实例。我们不知道该服务器的名称。

如果您要连接的实例是ITPL_PC1 上的默认实例,那么第一个版本应该始终有效(前提是ITPL_PC1 可以解析)。

【讨论】:

  • 谢谢你分配...。它刚刚工作...实际上Data Source=192.168.0.28\ITPL_PC1我通过谷歌搜索找到了这个所以我使用它但是谢谢
【解决方案2】:

Windows 安全可能会阻止访问。您可以尝试以下方法。
1.在运行窗口输入services.msc进入windows服务管理控制台。
2. 在显示的窗口中,您可以看到服务列表。从列表中找出Base Filtering Engine
3.右键单击并停止它。完成了

经过大量谷歌搜索后,我已经修复了类似的问题。(对我来说,即使在从 sql 配置管理器启用 TCP/IP 后它也无法正常工作)

【讨论】:

    【解决方案3】:
               First you open SQL managnebt studio and connect to another pc sql server :
    
             Please follow bolew step :
                Strat -> program -> window sql server 2008 -> configuration tools 
                --> sql server Configuration manager -->
                Start sql server browser service
        -----------
        Next --->Sql serverNetework COnfiguration  --> Enable all Protocls and
        also Sql Native Client.. --> Enable all Protocls  then
        --------------
        reatsrt all service and connect to sql
    -------------------------------------------------
    If you get connection then SQL Database to connect database from visual studio from there to find connection string and copy and paste to connection string.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2015-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多