SQL Server conn字符串。带远程计算机需要IP:PORT和SQLPORT [英] SQL Server conn string. w/ remote machine requires IP:PORT and SQLPORT

查看:119
本文介绍了SQL Server conn字符串。带远程计算机需要IP:PORT和SQLPORT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是尝试在C#中创建一个连接字符串,该字符串远程连接到SQL Server 2012数据库。如果托管SQL Server的计算机不需要端口号即可导航,则可以成功完成此操作。现在我们已经重新路由了一些IP,到托管SQL Server的计算机的IP是XXX.XXX.XXX.XXX:16500,其中SQL Server仍在侦听默认端口1433。

My problem is trying to create a connection string in C# which connects to a SQL Server 2012 database remotely. I can successfully do this if the machine hosting the SQL Server does not require a port number to navigate to. Now that we have re-routed our ip's a little, the ip to the machine hosting SQL Server is XXX.XXX.XXX.XXX:16500, where SQL Server is still listening on default port 1433.

我知道您可以像这样指定SQL Server实例正在使用的端口号;

I understand you can specify the port number that the SQL Server instance is using like so;

data source=XXX.XXX.XXX.XXX,1433;Network Library=DBMSSOCN;initial catalog=Order;User ID=test1;Password=test1;");

我们的问题是,我们的远程计算机不仅仅是IP,而是IP和端口。

Our problem is, that our remote machine is not just an IP. It is an IP and a port.

XXX.XXX.XXX.XXX:16500 会手动导航到所需的PC,而忽略端口号会将您带到另一台计算机。

XXX.XXX.XXX.XXX:16500 would manually navigate to the desired PC, ignoring the port number would take you to another machine. We are trying to accomplish something like this;

data source=XXX.XXX.XXX.XXX:16500,1433;Network Library=DBMSSOCN;initial catalog=Order;User ID=test1;Password=test1;");

我一生都找不到怎么做的方法。我想将数据源设置为远程IP:PORT,以及设置SQL Server侦听的端口(我知道默认值为1433,但是在某些情况下我们可能必须更改它,因此需要将其更改为

I cannot find for the life of me how to do this. I want to set my data source to a remote IP:PORT, as well as set the port SQL Server will be listening on (I understand 1433 is the default, but in some cases we may have to change it, so it needs to be there for the future)

我已经尝试过了

data source=XXX.XXX.XXX.XXX:16500,1433;Network Library=DBMSSOCN;initial catalog=Order;User ID=test1;Password=test1;");

错误:


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



data source=XXX.XXX.XXX.XXX:16500;Network Library=DBMSSOCN;initial catalog=Order;User ID=test1;Password=test1;");

错误:



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



data source=XXX.XXX.XXX.XXX,16500;Network Library=DBMSSOCN;initial catalog=Order;User ID=test1;Password=test1;");

错误:


已成功与服务器建立连接,但随后
在登录前握手期间发生错误。(提供程序:TCP
提供程序,错误:0-现有连接被
远程主机强行关闭了。)

在这里,看来我只是在连接错误服务器,尝试将端口16500用于SQL Server,这是不正确的。

Here it seems I am just connecting to the wrong server, trying to use port 16500 for SQL Server, which is not correct.

任何人都可以照亮一下,这有可能吗?

Can anyone please shine some light, is this possible?

推荐答案

这听起来像是您的IP地址ve实际上是一个NAT设备,它将流量转发到用于连接该端口的另一台计算机。在这种情况下,您需要让NAT管理员在NAT上创建一个公共端口,该公共端口将被转发到SQL Server计算机上的端口1433。任何端口转发始终只能转发到单个端口,因此,如果未设置新的转发规则,则您尝试执行的操作将无法进行。

This sounds like the IP address you have is actually a NAT device that forwards the traffic to another machine base on the port that was used to connect to it. If this is the case, you need to get your NAT administrator to create a public port on the NAT that will be forwarded to port 1433 on your SQL Server machine. Any port forwarding always only forwards to a single port, so what you were trying to do cannot work without that new forwarding rule being set up.

这篇关于SQL Server conn字符串。带远程计算机需要IP:PORT和SQLPORT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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