fixed a bug with OE connection changed the db name and blocked restore (#570)

This commit is contained in:
Leila Lali
2018-01-02 10:57:37 -08:00
committed by GitHub
parent 1c2b44fe74
commit 0ccc01eda9

View File

@@ -414,6 +414,19 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
}
response.Nodes = nodes;
response.ErrorMessage = node.ErrorMessage;
try
{
// SMO changes the database when getting sql objects. Make sure the database is changed back to the original one
if (bindingContext.ServerConnection.CurrentDatabase != bindingContext.ServerConnection.DatabaseName)
{
bindingContext.ServerConnection.SqlConnectionObject.ChangeDatabase(bindingContext.ServerConnection.DatabaseName);
}
}
catch(Exception ex)
{
Logger.Write(LogLevel.Warning, $"Failed to change the database in OE connection. error: {ex.Message}");
// We should just try to change the connection. If it fails, there's not much we can do
}
return response;
});