无法从另一台计算机连接SQL Server 2008 [英] cannot connect sql server 2008 from another computer

查看:162
本文介绍了无法从另一台计算机连接SQL Server 2008的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

System.Data.SqlClient.SqlException与网络有关或与实例有关的错误

我在c#中有winform应用程序,该应用程序连接到我自己的数据库,并且它的工作正常,我当前的sql连接字符串为:

i have winform application in c# which connect to my own db and its working fine my current sql connection string is :

SqlConnection con = new SqlConnection("Data Source=ITPL_PC1;Initial Catalog=Data_Project;Persist Security Info=True;user id=sa;Password=insforia"); 

但是当我将此Winform带到另一台计算机时,它无法正常工作..那我就改变了连接字符串至:

but when i am taking this winform to another computer its not working .. then i am changing my connection string to :

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中的所有设置,但仍然显示错误

i have changed all the settings in sql server of remote access but still it showing an error

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) 

是我的连接字符串错了吗?

is my connection string is wrong? what it should be?

请帮忙

推荐答案

Data Source=ITPL_PC1

标识服务器称为 ITPL_PC1 。您正在连接到该服务器上的默认实例。

Identifies a server called ITPL_PC1. You're connecting to the default instance on this server.

Data Source=192.168.0.28\ITPL_PC1

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

Identifies an instance called ITPL_PC1 running on a server with IP address 192.168.0.28. We don't know the name of this server.

如果要连接的实例是 ITPL_PC1 ,则第一个版本应始终有效(只要可以解决 ITPL_PC1 )。

If the instance you want to connect to is the default instance on ITPL_PC1, then the first version should always work (provided ITPL_PC1 can be resolved).

这篇关于无法从另一台计算机连接SQL Server 2008的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆