开发者

How to specify a port number in SQL Server connection string?

开发者 https://www.devze.com 2023-02-16 10:12 出处:网络
I use the following connection string in SQL Server Management Studio. It failed to connect: mycom开发者_C百科puter.test.xxx.com:1234\\myInstance1

I use the following connection string in SQL Server Management Studio. It failed to connect:

mycom开发者_C百科puter.test.xxx.com:1234\myInstance1

But the following one is ok:

mycomputer.test.xxx.com\myInstance1

So how do I specify a port number in a connection string?


Use a comma to specify a port number with SQL Server:

mycomputer.test.xxx.com,1234

It's not necessary to specify an instance name when specifying the port.

Lots more examples at http://www.connectionstrings.com/. It's saved me a few times.


For JDBC the proper format is slightly different and as follows:

jdbc:microsoft:sqlserver://mycomputer.test.xxx.com:49843

Note the colon instead of the comma.


The correct SQL connection string for SQL with specify port is use comma between ip address and port number like following pattern: xxx.xxx.xxx.xxx,yyyy

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号