Restore new connection string for multiple similar connections (#2067)

This commit is contained in:
Alex Ma
2023-06-15 23:31:40 -07:00
committed by GitHub
parent cef3564011
commit 6fe0b300e5
5 changed files with 79 additions and 3 deletions

View File

@@ -1044,7 +1044,29 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
{
try
{
connection.Close();
bool disconnect = false;
if (connection.ConnectionString != null){
int totalCount = 0;
foreach (KeyValuePair<string, ConnectionInfo> entry in OwnerToConnectionMap)
{
foreach (DbConnection value in entry.Value.AllConnections) {
if(value.ConnectionString == connection.ConnectionString) {
totalCount++;
}
}
}
if(totalCount == 1) {
disconnect = true;
}
}
else {
disconnect = true;
}
if(disconnect) {
connection.Close();
}
}
catch (Exception)
{