+1  A: 

You can do it through some COM Introp...but then you have to pull in a bunch of Interop assemblies into your project which can be a drag. This code will show the dialog using reflection instead.

public static string ShowDialog( IWin32Window owner, 
                                 string connectionString )
{
    Type dlType = Type.GetTypeFromProgID( "DataLinks", true );
    Type acType = Type.GetTypeFromProgID( "ADODB.Connection", true );

    object form = Activator.CreateInstance( dlType );
    object connection = Activator.CreateInstance( acType ); 

    acType.InvokeMember( 
        "ConnectionString", 
        BindingFlags.Public | BindingFlags.SetProperty, 
        null, 
        connection, 
        new object[]{ connectionString } 
        );  
    object result = 
    dlType.InvokeMember( 
        "PromptEdit", 
        BindingFlags.Public | BindingFlags.InvokeMethod, 
        null, 
        form, 
        new object[]{ connection } 
        );       
    if( result != null && (bool)result )
        return acType.InvokeMember( 
                 "ConnectionString", 
                 BindingFlags.Public | BindingFlags.GetProperty, 
                 null, 
                 connection, 
                 new object[]{} ) as string;

    return null;
}

This basically translates to the following VB Script

form = GetObject( "DataLinks" )
connection = GetOBject( "ADODB.Connection" )
connection.ConnectionString = "existing connection"
form.PromptEdit( connection )
Return connection.ConnectionString
Paul Alexander
I am again stacked on this issue,Now I try to send connection sting from app.config file to fill up Initial parameters but I alway get exeption on object result=dlType.InvokeMember.Any adviceThanx in advice
adopilot
Sure...what's the exception?
Paul Alexander
Might actually help to open a new question on SO so the entire problem/resolution can be documented for others.
Paul Alexander
Thanx on Your attention Ill try yet for while If I couldn't figure it Then I am going to open new SO, But I am kind shamed asking over and over people to do code for me.Best regards
adopilot
No shame...we all have to learn somewhere. Alot of this stuff is just down right bizzare and you only learn by banging your head on the wall for days at a time.
Paul Alexander
+1  A: 

More on that here.

JP Alioto
+1  A: 

I think that the best choice is to use the code provided from Microsoft here: http://code.msdn.microsoft.com/Connection.

It is the connection dialog used inside Visual Studio.

However, it only works with registered ADO.NET providers.

Adriano Machado