How to show connection information of the file in the properties window in Visual Studio

Vasu Bansal 20 Reputation points
2025-07-08T09:47:46.68+00:00

I am opening a new/existing file using this way

Guid editorFactory = new Guid(<GUID>);
VsShellUtilities.OpenDocumentWithSpecificEditor(
		ServiceProvider.GlobalProvider,
		openFileDialog.FileName,
		editorFactory,
		VSConstants.LOGVIEWID_Primary,
		out IVsUIHierarchy hierarchy,
		out uint itemID,
		out IVsWindowFrame windowFrame
);
windowFrame?.Show();

and after creating a connection to that file i want to show the connection string, status etc information in the properties window of visual studio

Similar to what happens when we open a .sql file from the File menu > open > sql file, in properties window we get this

User's image

How can i do that after opening a file.

Developer technologies | Visual Studio | Extensions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Surya Amrutha Vaishnavi Lanka (INFOSYS LIMITED) 335 Reputation points Microsoft External Staff
    2025-07-29T08:05:22.8566667+00:00

    To show the connection info (like connection status) in the Properties window after opening a .sql file, you need to open the file using the SQL editor used by Visual Studio.

    Use this code:

    Guid sqlEditorGuid = new Guid("FBA1F4DC-8EC1-49E4-A09D-A8FE6D4F8B24"); // SQL editor GUID

    VsShellUtilities.OpenDocumentWithSpecificEditor(

        ServiceProvider.GlobalProvider,

        filePath,

        sqlEditorGuid,

        VSConstants.LOGVIEWID_Primary,

        out IVsUIHierarchy hierarchy,

        out uint itemID,

        out IVsWindowFrame windowFrame

    );

    windowFrame?.Show();


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.