title: Specifying Port With SqlConnectionStringBuilder?
body: <p>I've ran into a snag. I have a need to specify the port number for my local installation of SQL Server 2008 R2. So far I've tried using the SqlConnectionStringBuilder with the data source set as <code>.\TESTSERVER, 1433</code>, which by all the documentation should connect me to the server TESTSERVER on port 1433 (the default). </p>
  
  <p>The connection string looks like:</p>
  
  <p><code>{Data Source=".\TESTSERVER, 1433";Initial Catalog=AdventureWorks;User ID=testuser;Password=MYPASSWORDHERE}</code></p>
  
  <p>However I get an error that looks like:</p>
  
  <blockquote>
    <p>A network related or instance-specific error has occurred while establishing a connection SQL server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL server is configured to allow remote connections. (Provider: TCP provider, error:0 - no connection could be made because the target machine actively refused it. </p>
  </blockquote>
  
  <p>Upon verifying the connection string using <code>SqlConnectionStringBuilder.ToString()</code> it comes out almost how <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx" rel="noreferrer">MSDN</a> suggests. For some reason it wraps double quotes ONLY around the data source and nothing else. However this may just be the debugger removing the outside quotes since it's stored in a <code>string</code> datatype. I also verified that SQL server is accessible without specifying the port and it is. Finally, I verified that the server is allowed to accept remote connections. Considering this instance of SQL Server is installed locally, using the default port, and on my development computer I couldn't imagine why I would be getting an error like this.</p>
  
  <p>Is this because the SqlConnectionStringBuilder is overriding my port with it's own port? Do I need to for some reason open up ports on my firewall? Knowing it's a fully local installation it shouldn't be encountering firewall problems. I'd rather not have to manually build the connection string. Not that it's difficult, it just adds a layer of complexity to my code I'd rather not have unless needed.</p>
  
  <p>Any help would be appreciated. Thanks!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>After a long hard digging through the SqlConnectionStringBuilder syntax it appears that it handles invalid parameters by passing then to the connection string surrounded in quotes. I'd imagine this is because it breaks the connectionstring. My question still remains: <strong>is there a way to pass port via SqlConnectionStringBuilder or will I have to build it myself?</strong></p>