Allow connections on non-default port (#462)

* Allow custom port

* Update unit tests for port property
This commit is contained in:
Karl Burtram
2017-09-21 08:26:13 -07:00
committed by GitHub
parent c90fd3410d
commit 60aad9cf7e
5 changed files with 109 additions and 55 deletions

View File

@@ -886,10 +886,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
{
connectionBuilder = new SqlConnectionStringBuilder(connectionDetails.ConnectionString);
}
else {
else
{
// add alternate port to data source property if provided
string dataSource = !connectionDetails.Port.HasValue
? connectionDetails.ServerName
: string.Format("{0},{1}", connectionDetails.ServerName, connectionDetails.Port.Value);
connectionBuilder = new SqlConnectionStringBuilder
{
["Data Source"] = connectionDetails.ServerName,
["Data Source"] = dataSource,
["User Id"] = connectionDetails.UserName,
["Password"] = connectionDetails.Password
};