Loading of connection string with SQL Server Data Tools installed

Answered Loading of connection string with SQL Server Data Tools installed

  • Tuesday, December 04, 2012 8:35 AM
     
     

    Hi.

    I use ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo (from Microsoft.SqlServer.SqlTools.VSIntegration.VS.dll assembly) to get connection string for currently opened tab.

    The problem is that if SQL Server Data Tools is installed NullReferenceException will be generated in ServiceCache.ScriptFactory property.

    Analyzed disassembled propery and found that service provider is null. The only ways to initialize it - use SQLWorkbenchPackage.SetSite or ServiceCache.Init methods. But in this case IServiceProvider should be implemented.

    Tried to use ScriptFactory.Instance.CurrentlyActiveWndConnectionInfo (from SQLEditors.dll assembly). But COMException is generated - after disassembling found that it happens because current connection isn't found.

    Guys, any thoughts? How can I load connection information when SSDT is installed?

    UPDATE: Tried to use DTE as IServiceProvider instance - current connection wasn't found (CurrentlyActiveWndConnectionInfo property value is null).


    Nickolay Laptev



All Replies

  • Thursday, December 06, 2012 2:09 AM
     
     

    Hi,

    Based on this issue related to Sql, I am suggesting you go to sql forum to get help.

    I am moving this thread to SQL Server Data Tools forum.

    Thank you for your understanding and support.

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Monday, December 10, 2012 5:35 AM
    Moderator
     
     
    Which connection do you want to clone? As far as I know only the Server Explorer data connections connection can be cloned. SSDT does not provide an extensible API for this.

    -GertD @ www.sqlproj.com

  • Monday, December 10, 2012 5:50 AM
     
     

    I want nothing to clone. The only thing I want to get connection string (or SqlConnection instance) of currently opened sql tab. And the problem is that SSDT "breaks" working method.

    Server Explorer data doesn't match as I can open sql tab (CTRL+O any sql file), manage connection for this tab and there is no connection in Server Explorer at the same time.

    I suspect SSDT provides another solution for my problem. Otherwise it breaks working one.


    Nickolay Laptev

  • Monday, December 10, 2012 5:57 AM
    Moderator
     
     
    As far as I know we don't allow you to get to the SqlConnection of the SQL editor due to security restrictions, we never allowed this.

    -GertD @ www.sqlproj.com

  • Monday, December 10, 2012 6:04 AM
     
     

    Hm. You can successfully get SqlConnection (with password protected) from Server Explorer in MSVS 2005/2008/2010/2012.

    I hope there is a way to get it for opened tab too.


    Nickolay Laptev

  • Tuesday, December 11, 2012 7:05 PM
    Moderator
     
     Answered
    There is none, sorry.

    -GertD @ www.sqlproj.com

  • Wednesday, December 12, 2012 4:40 AM
     
     
    Thanks!

    Nickolay Laptev