title: SQL Server conn string. w/ remote machine requires IP:PORT and SQLPORT
body: <p>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.</p>
  
  <p>I understand you can specify the port number that the SQL Server instance is using like so;</p>
  
  <pre><code>data source=XXX.XXX.XXX.XXX,1433;Network Library=DBMSSOCN;initial catalog=Order;User ID=test1;Password=test1;");
  </code></pre>
  
  <p>Our problem is, that our remote machine is not just an IP. It is an IP and a port.</p>
  
  <p><code>XXX.XXX.XXX.XXX:16500</code> 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;</p>
  
  <pre><code>data source=XXX.XXX.XXX.XXX:16500,1433;Network Library=DBMSSOCN;initial catalog=Order;User ID=test1;Password=test1;");
  </code></pre>
  
  <p>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)</p>
  
  <p>I have tried;</p>
  
  <pre><code>data source=XXX.XXX.XXX.XXX:16500,1433;Network Library=DBMSSOCN;initial catalog=Order;User ID=test1;Password=test1;");
  </code></pre>
  
  <p>ERROR: </p>
  
  <blockquote>
    <p><em>A network-related or instance-specific error occured while
    establishing a connection to the SQL Server...</em></p>
  </blockquote>
  
  <pre><code>data source=XXX.XXX.XXX.XXX:16500;Network Library=DBMSSOCN;initial catalog=Order;User ID=test1;Password=test1;");
  </code></pre>
  
  <p>ERROR: </p>
  
  <blockquote>
    <p><em>A network-related or instance-specific error occured while
    establishing a connection to the SQL Server...</em></p>
  </blockquote>
  
  <pre><code>data source=XXX.XXX.XXX.XXX,16500;Network Library=DBMSSOCN;initial catalog=Order;User ID=test1;Password=test1;");
  </code></pre>
  
  <p>ERROR: </p>
  
  <blockquote>
    <p><em>A connection was successfully established with the server, but then
    an error occurred durring the pre-login handshake. (Provider: TCP
    Provider, error:0 - An existing connection was forcibly closed by the
    remote host.)</em></p>
  </blockquote>
  
  <p>Here it seems I am just connecting to the wrong server, trying to use port 16500 for SQL Server, which is not correct.</p>
  
  <p>Can anyone please shine some light, is this possible?</p>