Using the server name tcp:<public IP>,<port> , as described in SqlConnection.ConnectionString :
The name or network address of the instance of SQL Server to which you are connecting. The port number can be specified after the server name:
server=tcp:servername, portnumber
When specifying a local instance, always use (locally). To force the protocol, add one of the following prefixes:
np:(local) , tcp:(local) , lpc:(local)
The data source must use the TCP format or the Named Pipes format.
The TCP format is as follows:
tcp:<host name>\<instance name>tcp:<host name>,<TCP/IP port number>
If you use tcp:<host name>\<isntance name> , you need to connect to the SQL Browser service (port 1433), so it is better to use a later format with an explicit port name:
Data Source=tcp:1.2.3.4,1234;User Id=...; Password=...
Remus Rusanu
source share