Accessing SQL Server using an IP Address and Port Number … Help!

折月煮酒 提交于 2019-12-08 02:38:15

问题


I need to access an SQL Server that is on a machine behind a firewall and you access this machine using an ip address like 95.95.95.33:6930 (not the real ip address) ... But, you get my point that by accessing 95.95.95.33 on port 6930, the firewall routes the requests to that particular machine ...

My question is ... How do you construct a connection string to access the machine at address 95.95.95.33:6930 and then further access the SQL Server on port 1433 or maybe a different port like 8484 ???

Thanks

Mike


回答1:


well, you build the connection string like this

"Server=95.95.95.33,6930;database=mydb;..."

the firewall/nat will have to route that to the correct machine/port of the SQL server for you.




回答2:


All you should worry about is the public address and port number of the SQL server. It makes no difference to you to which internal machine and port number the connection is forwarded to.

You then build a connection string as described on connectionstrings.com:

Data Source=95.95.95.33,6930;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;

DBMSSOCN=TCP/IP. This is how to use TCP/IP instead of Named Pipes. At the end of the Data Source is the port to use. 1433 is the default port for SQL Server.



来源:https://stackoverflow.com/questions/2630246/accessing-sql-server-using-an-ip-address-and-port-number-help

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!