I have been racking my brain trying to figure out how to set the SQLConnection for a VSIX designed for SSMS. The closest I have come is to cast the active window to a SqlScriptEditorControl which has a SetConnection method. The problem is this only seems to assign the SqlScriptEditorControl in SSMS19 and the changes that are applied don't actually change the connection in SSMS.
Window activeWindow = activeDocument.ActiveWindow;
SqlScriptEditorControl editorControl = activeWindow.Object as SqlScriptEditorControl;
UIConnectionInfo newInfo = getUIConnectionfromRegisteredServer(newConnection);
editorControl.SetConnection(newInfo);
Does anyone know how you can change the connection in VSIX and have it apply to the activewindow in SSMS?
What I'm expecting is to be able to assign the UICOnnectionInfo for the currently active window / active document in SSMS.
Please try this
c#code and tell me if it works for. I couldn't test because I am not having theIDE