diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs index ec25fd6c..d9a886d4 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs @@ -177,12 +177,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution { HasError = true; UnwrapDbException(dbe); - conn?.Dispose(); } catch (Exception) { HasError = true; - conn?.Dispose(); throw; } finally diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs index 942beef3..5b26eafc 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs @@ -213,6 +213,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution } catch (InvalidOperationException e) { + // If this exception occurred, we most likely were trying to cancel a completed query await requestContext.SendResult(new QueryCancelResult { Messages = e.Message