locked
Connection string design-time editor RRS feed

  • Question

  • I'd like to create a user control that has a connection string property that allows the user to setup a connection at design time in the same fashion as in Project settings or TableAdapters. 

     

    When a someone adds this control to their form, there will be a property called ConnectionString that when it is clicked (via the Properties grid), it will bring up the Connection Properties dialog box. 

     

    I'd like to know if this is possible using ComponentModel attributes, and if so, which one?

     

    Thanks,

    J

    Friday, June 1, 2007 5:17 PM

Answers

  •  

    Hi J Russo,

     

    Try like this:

    Code Snippet

    namespace UserControls

    {

        public partial class UserControl1 : UserControl

        {

            public UserControl1()

            {

                InitializeComponent();

            }

     

            private string _connectionstring;

     

            [RefreshProperties(RefreshProperties.All),  RecommendedAsConfigurable(true), DefaultValue(""), Editor("Microsoft.VSDesigner.Data.SQL.Design.SqlConnectionStringEditor, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]

            public string Connectionstring

            {

                get { return _connectionstring; }

                set { _connectionstring = value; }

            }

        }

    }

     

    Hope this helps.

     

    Regards

    Thursday, June 7, 2007 9:01 AM
  • I found IT
     

    Editor("Microsoft.VSDesigner.Data.ADO.Design.OleDbConnectionStringEditor, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

     

    thanks

    Sunday, September 23, 2007 9:54 AM

All replies

  •  

    Hi J Russo,

     

    Try like this:

    Code Snippet

    namespace UserControls

    {

        public partial class UserControl1 : UserControl

        {

            public UserControl1()

            {

                InitializeComponent();

            }

     

            private string _connectionstring;

     

            [RefreshProperties(RefreshProperties.All),  RecommendedAsConfigurable(true), DefaultValue(""), Editor("Microsoft.VSDesigner.Data.SQL.Design.SqlConnectionStringEditor, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]

            public string Connectionstring

            {

                get { return _connectionstring; }

                set { _connectionstring = value; }

            }

        }

    }

     

    Hope this helps.

     

    Regards

    Thursday, June 7, 2007 9:01 AM
  • I got the error message box below...

     

    DataConnectionsServiceWrap cannot ne created without a ServerExplorer service.

    Tuesday, July 17, 2007 4:24 AM
  •  

    Hi,

     

    Which version of IDE did you use? I use the Visual Studio 2005.

    Thanks

     

    With Regards

     

    Tuesday, July 17, 2007 4:38 AM
  • Dear Sir
    I tried the code you posted but Editor you used allow to build SQL connections only, Is there other Editors help building other databases connections.

    Also where I can find documentations for those editors?

    Regards,
    Ahmed Hashish

    Thursday, September 20, 2007 11:29 AM
  • I found IT
     

    Editor("Microsoft.VSDesigner.Data.ADO.Design.OleDbConnectionStringEditor, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

     

    thanks

    Sunday, September 23, 2007 9:54 AM
  • Dear Sir

    I got the following error "could not load file or assembly Microsoft.VisualStudio.Data, ... The system can not find the specified file" when I'm trying to build the connection string in the run time.
    It's working in the design time.

    In my application I'm creating my own windows form designer to help users to create their own simple databound forms
    when the user add my control to the designer and try to build the connection string the above error raise

    regards,
    Ahmed
    Wednesday, October 10, 2007 12:34 PM