1

I develop an addin for MSVS 2012. I need to get connection string for tsql tab currently opened.

I used IScriptFactory interface members to get connection string in MSVS 2010 (I use ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo property). IScriptFactory interface is defined in Microsoft.SqlServer.SqlTools.VSIntegration.VS.dll assembly.

For SSMS 2012 I use the same interface but defined in SqlPackageBase.dll assembly.

I can find neither Microsoft.SqlServer.SqlTools.VSIntegration.VS.dll nor SqlPackageBase.dll assemblies in MSVS 2012 (Ultimate RTM) installed folder.

Also I tried to find CurrentlyActiveWndConnectionInfo class and IScriptFactory interface in all MSVS 2012 assemblies installed but found nothing.

How can I get connection string for current tsql tab in MSVS 2012?

nickolay.laptev
  • 2,253
  • 1
  • 21
  • 31

1 Answers1

1

SQLEditors.dll ("...\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Extensions\Application\SQLEditors.dll ") assembly contains required information. I tried to use ScriptFactory.Instance.CurrentlyActiveWndConnectionInfo property but it generates InvalidOperationException. Here is the result of CurrentlyActiveWndConnectionInfo property disassembling:

public CurrentlyActiveWndConnectionInfo CurrentlyActiveWndConnectionInfo
{
    get
    {
        STrace.Params("ScriptFactory", "ScriptFactory.CurrentlyActiveWndConnectionInfo", string.Empty, null);
        if (ServiceCache.VSMonitorSelection == null)
        {
            STrace.LogExThrow();
            throw new InvalidOperationException();
        }
        return this.GetCurrentlyActiveWndConnectionInfo(ServiceCache.VSMonitorSelection);
    }
}

I think the problem in null ServiceCache.VSMonitorSelection.

nickolay.laptev
  • 2,253
  • 1
  • 21
  • 31
  • Any chance you could post a code snippet for this? I am also interested in how the connection string can be retrieved :) – Dan Nolan Sep 26 '12 at 15:41