mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
fixed a bug with OE connection changed the db name and blocked restore (#570)
This commit is contained in:
@@ -414,6 +414,19 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
}
|
}
|
||||||
response.Nodes = nodes;
|
response.Nodes = nodes;
|
||||||
response.ErrorMessage = node.ErrorMessage;
|
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;
|
return response;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user