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
- Moved by Ego JiangMicrosoft Contingent Staff Thursday, December 06, 2012 2:09 AM It is a sql server thread (From:Visual Studio Extensibility)
- Edited by Nickolay Laptev Thursday, December 06, 2012 6:29 AM
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 AMModeratorWhich 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 AMModeratorAs 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
- Proposed As Answer by Janet YeildingMicrosoft Employee, Owner Monday, December 10, 2012 10:56 PM
- Unproposed As Answer by Nickolay Laptev Tuesday, December 11, 2012 6:43 AM
-
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 PMModerator
There is none, sorry.-GertD @ www.sqlproj.com
- Proposed As Answer by Janet YeildingMicrosoft Employee, Owner Wednesday, December 12, 2012 1:09 AM
- Marked As Answer by Nickolay Laptev Wednesday, December 12, 2012 4:40 AM
-
Wednesday, December 12, 2012 4:40 AMThanks!
Nickolay Laptev

