如何使用ip地址连接远程sql server [英] How to connect with remote sql server using ip address

查看:114
本文介绍了如何使用ip地址连接远程sql server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用以下方式获取目标计算机的IP地址:

昏暗主机名为 String  = Dns.GetHostName()
Dim vrIPAddress As String = CType(Dns.GetHostByName(hostname).AddressList.GetValue(< span class =code-digit> 0 ),IPAddress).ToString





然后我试过使用连接字符串与该计算机连接:

  数据源= 192.168.0.2,1433 \ MyInstance;网络库= DBMSSOCN;初始目录= myDataBase;用户ID = myUsername;密码= myPassword;  





经过长时间停顿后,它说:

与网络相关的实例特定的错误发​​生建立连接 to  SQL Server。服务器找到 无障碍。验证实例名称 正确 SQL Server 配置 允许远程连接。 (提供者:TCP提供者,错误: 0   - 连接尝试失败,因为连接方 正确响应在 时间段之后,建立的连接失败,因为已连接的主机已失败回复。)





目标系统配置为防火墙,允许远程连接等,允许两个TCP / IP连接。



请指教。

谢谢



我尝试了什么:



我搜索了谷歌,尝试了不同的代码片段

解决方案

< blockquote> sql连接的端口在服务器级别没有打开,除非你通过端口获得正确的IP地址,否则你不能做同样的事情。


如果你正在尝试连接到MS SQL Server放置o在另一台计算机上,看看这里:

第2课:从另一台计算机连接 [ ^ ]

如何:启用TCP / IP协议数据库实例 [ ^ ]

在某些情况下,您需要配置Windows防火墙以允许SQL Server访问 [ ^ ]



但是,似乎你想在本地机器上连接到MS SQL Server。您可以在此处找到有关连接字符串的许多有用信息: SQL Server连接字符串 - ConnectionStrings.com [ ^ ]


Hi,
I obtained IP address of the target computer using:

Dim hostname As String = Dns.GetHostName()
       Dim vrIPAddress As String = CType(Dns.GetHostByName(hostname).AddressList.GetValue(0), IPAddress).ToString



Then i tried to connect with that computer using connection string:

"Data Source=192.168.0.2,1433\MyInstance;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;



After a long pause, it says:

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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)



The target system is configured for Firewall, allows Remote Connection etc, allows both TCP/IP connections.

Please advise.
Thanks

What I have tried:

I have searched google, tried different code snippets

解决方案

The port for sql connection is not open at the server level and you cant do much about the same unless you are getting the proper ip address with the port.


If you're trying to connect to MS SQL Server placed on another computer, take a look here:
Lesson 2: Connecting from Another Computer[^]
How to: Enable the TCP/IP Protocol for a Database Instance[^]
In some cases, you'll need to Configure the Windows Firewall to Allow SQL Server Access[^]

But, it seems you want to connect to MS SQL Server on local machine. Many useful information about "connection string" you'll find here: SQL Server connection strings - ConnectionStrings.com[^]


这篇关于如何使用ip地址连接远程sql server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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