Connection Information property Editor RRS feed

  • Question

  • Hello

    I am looking into write a custom datagenerator for a datageneration plan. I found the article (and the code download) very helpful: http://visualstudiomagazine.com/articles/2007/05/29/build-a-custom-databound-generator.aspx.

    In this sample the System.Web.UI.Design.ConnectionStringEditor is used for the ConnectionString Input property. This editor is quite simple, it just shows a pop up dialog where the user can enter a connection string.

    Is there any other class available somewhere that implements the 'Connection Information' property editor that is used by the built-in Data Bound Generator. I mean the editor that will show a dropdown of the Data Connections already defined in the Server Explorer?



    Wednesday, October 27, 2010 3:44 PM


  • Hi Lars,

    Sorry about the slow response on this one. I'm not really familiar with database projects, or custom data generators. But after poking around a bit, I suspect what you are referring to here, is how to get the list of existing connections in the server explorer toowindow, similar to how the "Connection Information" dropdown in the Properties dialog is populated.

    I believe that we use the DataExplorerConnectionManager to enumerate/list the available connections. I haven't seen any example usage of this class, but I have successfully used the IVsDataExplorerConnectionManager to iterate through the various connections in the Server Explorer toolwindow. For example:

    namespace SEAddin
        using System;
        using Extensibility;
        using EnvDTE;
        using EnvDTE80;
        using Microsoft.VisualStudio.Shell;
        using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
        using Microsoft.VisualStudio.Data.Services;

    public class Connect : IDTExtensibility2
         private DTE2 _applicationObject;
            private AddIn _addInInstance;
            private ServiceProvider _serviceProvider;

            public Connect() { }

    public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
                _serviceProvider = new ServiceProvider((IOleServiceProvider)application);

                IVsDataExplorerConnectionManager expCM = (IVsDataExplorerConnectionManager)_serviceProvider.GetService(typeof(IVsDataExplorerConnectionManager));
                var connections = expCM.Connections;

                foreach (string key in connections.Keys)
                    IVsDataExplorerConnection connection = connections[key];

    public void OnDisconnection(ext_DisconnectMode disconnectMode, ref Array custom) {}
    public void OnAddInsUpdate(ref Array custom) {}
    public void OnStartupComplete(ref Array custom) {}
    public void OnBeginShutdown(ref Array custom) {}

    Also, if you want to display the same connection dialog, you could use IVsDataConnectionDialogFactory.CreateConnectionDailog.


    Ed Dore
    Monday, December 6, 2010 11:23 PM