none
SSMS Addin and the current document connection RRS feed

  • Question

  •  

    I have a VSIP package loaded into SSMS.  I want to be notified when the connection on the current window changes.

    I have managed to get *part* of the current window's connection with the following code:

    Microsoft.SqlServer.Management.UI.VSIntegration.Editors.IScriptFactory scriptFactory = ServiceCache.ScriptFactory;
    CurrentlyActiveWndConnectionInfo connInfo = scriptFactory.CurrentlyActiveWndConnectionInfo;

    but that connection info object does not have the database name in it!  I found the ISqlScriptWindowWithConnection interface (in Microsoft.SqlServer.Management.UI.VSIntegration.Editors), and it contains an event named NewConnectionForScript... sounds just like what I need, eh?  But I can't get an instance of that interface anywhere!!!!  I've tried seemingly a million different routes. 

    So the question is, does anyone know how I can get an object that implements the ISqlScriptWindowWithConnection interface for the current document?  Or any other way that I can get the connection info associated with the current document window?

    ~Steve

     

    Friday, November 17, 2006 4:23 AM

All replies

  • Did you ever find out how to do this? I too would like to write an addon that uses the current query window's connection info, including the current database name if possible. I think the problem might be that the current database is dynamic "inside" the window (ie, you can have a "use [db]" inside a window and so the database isn't a property of the window). But there must be some other way.... right?
    Saturday, July 10, 2010 8:06 PM