none
Loading of connection string with SQL Server Data Tools installed

    Question

  • 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



    Tuesday, December 04, 2012 8:35 AM

Answers

All replies

  • 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.

    Thursday, December 06, 2012 2:09 AM
  • 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:35 AM
    Moderator
  • 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:50 AM
  • 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 5:57 AM
    Moderator
  • 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

    Monday, December 10, 2012 6:04 AM
  • There is none, sorry.

    -GertD @ www.sqlproj.com

    Tuesday, December 11, 2012 7:05 PM
    Moderator
  • Thanks!

    Nickolay Laptev

    Wednesday, December 12, 2012 4:40 AM