I wanted to create an extension to Visual Studio that displays the name of the database selected in Server Explorer. I've tried the following C# code.
var dte = Package.GetGlobalService(typeof(DTE)) as DTE2;
EnvDTE.UIHierarchy serverExplorer = dte.ToolWindows.GetToolWindow("Server Explorer");
object[] items = serverExplorer.SelectedItems as object[];
MessageBox.Show(items[0].ToString());
I need to find the name and credentials of the selected database in Server Explorer.
Also, items[0].ToString() returns System._ComObject. But I can find the name of the database at items[0] -> DynamicView -> Name.
Could anyone help me to find the name and credentials of the selected database?
Thanks in advance.