mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
Addressing feedback
This commit is contained in:
@@ -505,8 +505,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
if (TryFindConnection(ownerUri, out info))
|
if (TryFindConnection(ownerUri, out info))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
if (info.SqlConnection.State == ConnectionState.Open)
|
||||||
{
|
{
|
||||||
info.SqlConnection.ChangeDatabase(newDatabaseName);
|
info.SqlConnection.ChangeDatabase(newDatabaseName);
|
||||||
|
}
|
||||||
info.ConnectionDetails.DatabaseName = newDatabaseName;
|
info.ConnectionDetails.DatabaseName = newDatabaseName;
|
||||||
|
|
||||||
// Fire a connection changed event
|
// Fire a connection changed event
|
||||||
|
|||||||
@@ -21,6 +21,15 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Query : IDisposable
|
public class Query : IDisposable
|
||||||
{
|
{
|
||||||
|
#region Constants
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Error" code produced by SQL Server when the database context (name) for a connection changes.
|
||||||
|
/// </summary>
|
||||||
|
private const int DatabaseContextChangeErrorNumber = 5701;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -146,10 +155,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
{
|
{
|
||||||
await conn.OpenAsync();
|
await conn.OpenAsync();
|
||||||
|
|
||||||
if (conn.GetType() == typeof(SqlConnection))
|
SqlConnection sqlConn = conn as SqlConnection;
|
||||||
|
if (sqlConn != null)
|
||||||
{
|
{
|
||||||
// Subscribe to database informational messages
|
// Subscribe to database informational messages
|
||||||
SqlConnection sqlConn = conn as SqlConnection;
|
|
||||||
sqlConn.InfoMessage += OnInfoMessage;
|
sqlConn.InfoMessage += OnInfoMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,11 +170,6 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// "Error" code produced by SQL Server when the database context (name) for a connection changes.
|
|
||||||
/// </summary>
|
|
||||||
private const int DatabaseContextChangeErrorNumber = 5701;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for database messages during query execution
|
/// Handler for database messages during query execution
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user