Home All Groups Group Topic Archive Search About

invoke ado connection wizard at runtime C#

Author
3 Jan 2007 4:49 AM
Jack Wasserstein
Is it possible to invoke this wizard at runtime, using c#, if so how?

Author
3 Jan 2007 5:00 AM
Stephany Young
You need to add references to both of these COM libraries:

  Microsoft ActiveX Data Objects 2.8 Library
  Microsoft OLEDB Service Component 1.0 Type Library

If you want to generate a new connectionstring:

  public string NewConnectionString()
  {
    object _con = null;
    MSDASC.DataLinks _link =  new MSDASC.DataLinks();
    _con = _link.PromptNew();
    if (_con == null) return string.Empty;
    return ((ADODB.Connection)_con).ConnectionString;
  }

If you want to modify an existing connectionstring:

  public void ExistingConnection(ref string connectionstring)
  {
    MSDASC.DataLinks _link = new MSDASC.DataLinks();
    ADODB.Connection _con = new ADODB.Connection();
    _con.ConnectionString = connectionstring;
    if (_link.PromptEdit((object)_con))
    {
      connectionstring = _con.ConnectionString;
    }
  }


Show quote
"Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
message news:EB354E06-4073-4185-A65C-3EA56104311D@microsoft.com...
> Is it possible to invoke this wizard at runtime, using c#, if so how?
Author
3 Jan 2007 6:33 AM
Jack Wasserstein
Thanks Stephany,

but i dont see any of the .net data providers in the data link dialog box
that pops up?

Show quote
"Stephany Young" wrote:

> You need to add references to both of these COM libraries:
>
>   Microsoft ActiveX Data Objects 2.8 Library
>   Microsoft OLEDB Service Component 1.0 Type Library
>
> If you want to generate a new connectionstring:
>
>   public string NewConnectionString()
>   {
>     object _con = null;
>     MSDASC.DataLinks _link =  new MSDASC.DataLinks();
>     _con = _link.PromptNew();
>     if (_con == null) return string.Empty;
>     return ((ADODB.Connection)_con).ConnectionString;
>   }
>
> If you want to modify an existing connectionstring:
>
>   public void ExistingConnection(ref string connectionstring)
>   {
>     MSDASC.DataLinks _link = new MSDASC.DataLinks();
>     ADODB.Connection _con = new ADODB.Connection();
>     _con.ConnectionString = connectionstring;
>     if (_link.PromptEdit((object)_con))
>     {
>       connectionstring = _con.ConnectionString;
>     }
>   }
>
>
> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
> message news:EB354E06-4073-4185-A65C-3EA56104311D@microsoft.com...
> > Is it possible to invoke this wizard at runtime, using c#, if so how?
>
>
>
Author
3 Jan 2007 6:39 AM
Stephany Young
Ummmmmm ... That would be correct. Why would you expect to?


Show quote
"Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
message news:48D66AA9-EB32-4A10-9ABF-BB44A44DE2CB@microsoft.com...
> Thanks Stephany,
>
> but i dont see any of the .net data providers in the data link dialog box
> that pops up?
>
> "Stephany Young" wrote:
>
>> You need to add references to both of these COM libraries:
>>
>>   Microsoft ActiveX Data Objects 2.8 Library
>>   Microsoft OLEDB Service Component 1.0 Type Library
>>
>> If you want to generate a new connectionstring:
>>
>>   public string NewConnectionString()
>>   {
>>     object _con = null;
>>     MSDASC.DataLinks _link =  new MSDASC.DataLinks();
>>     _con = _link.PromptNew();
>>     if (_con == null) return string.Empty;
>>     return ((ADODB.Connection)_con).ConnectionString;
>>   }
>>
>> If you want to modify an existing connectionstring:
>>
>>   public void ExistingConnection(ref string connectionstring)
>>   {
>>     MSDASC.DataLinks _link = new MSDASC.DataLinks();
>>     ADODB.Connection _con = new ADODB.Connection();
>>     _con.ConnectionString = connectionstring;
>>     if (_link.PromptEdit((object)_con))
>>     {
>>       connectionstring = _con.ConnectionString;
>>     }
>>   }
>>
>>
>> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
>> message news:EB354E06-4073-4185-A65C-3EA56104311D@microsoft.com...
>> > Is it possible to invoke this wizard at runtime, using c#, if so how?
>>
>>
>>
Author
3 Jan 2007 6:49 AM
Jack Wasserstein
Perhaps I posted my question incorrectly, but i am looking to create a
connection string to a sql 2005 express database using the wizard at runtime.
Do you know how to call that one?

Show quote
"Stephany Young" wrote:

> Ummmmmm ... That would be correct. Why would you expect to?
>
>
> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
> message news:48D66AA9-EB32-4A10-9ABF-BB44A44DE2CB@microsoft.com...
> > Thanks Stephany,
> >
> > but i dont see any of the .net data providers in the data link dialog box
> > that pops up?
> >
> > "Stephany Young" wrote:
> >
> >> You need to add references to both of these COM libraries:
> >>
> >>   Microsoft ActiveX Data Objects 2.8 Library
> >>   Microsoft OLEDB Service Component 1.0 Type Library
> >>
> >> If you want to generate a new connectionstring:
> >>
> >>   public string NewConnectionString()
> >>   {
> >>     object _con = null;
> >>     MSDASC.DataLinks _link =  new MSDASC.DataLinks();
> >>     _con = _link.PromptNew();
> >>     if (_con == null) return string.Empty;
> >>     return ((ADODB.Connection)_con).ConnectionString;
> >>   }
> >>
> >> If you want to modify an existing connectionstring:
> >>
> >>   public void ExistingConnection(ref string connectionstring)
> >>   {
> >>     MSDASC.DataLinks _link = new MSDASC.DataLinks();
> >>     ADODB.Connection _con = new ADODB.Connection();
> >>     _con.ConnectionString = connectionstring;
> >>     if (_link.PromptEdit((object)_con))
> >>     {
> >>       connectionstring = _con.ConnectionString;
> >>     }
> >>   }
> >>
> >>
> >> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
> >> message news:EB354E06-4073-4185-A65C-3EA56104311D@microsoft.com...
> >> > Is it possible to invoke this wizard at runtime, using c#, if so how?
> >>
> >>
> >>
>
>
>
Author
6 Jan 2007 9:18 AM
Stephany Young
Stumbled across this by accident while I was looking for something else:

Step 1:

Add references to:

   Microsoft.Data.ConnectionUI.dll
   Microsoft.Data.ConnectionUI.Dialog.dll

   You will need to browse for them at C:\Program Files\Microsoft Visual
Studio 8\Common7\IDE
   (assuming that your VS2005 is installed to the default location)

Step 2:

  Wherever you want to use it, execute:

    Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog _dialog = new
Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog();

    Microsoft.Data.ConnectionUI.Dialog.DataSource.AddStandardDataSources(_dialog);

    Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog.Show(_dialog);

You will need to have a play with it to find out how to use it because I
have no further information than that.


Show quote
"Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
message news:3864EA6E-8A50-408D-98F0-7270683E0D73@microsoft.com...
> Perhaps I posted my question incorrectly, but i am looking to create a
> connection string to a sql 2005 express database using the wizard at
> runtime.
> Do you know how to call that one?
>
> "Stephany Young" wrote:
>
>> Ummmmmm ... That would be correct. Why would you expect to?
>>
>>
>> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
>> message news:48D66AA9-EB32-4A10-9ABF-BB44A44DE2CB@microsoft.com...
>> > Thanks Stephany,
>> >
>> > but i dont see any of the .net data providers in the data link dialog
>> > box
>> > that pops up?
>> >
>> > "Stephany Young" wrote:
>> >
>> >> You need to add references to both of these COM libraries:
>> >>
>> >>   Microsoft ActiveX Data Objects 2.8 Library
>> >>   Microsoft OLEDB Service Component 1.0 Type Library
>> >>
>> >> If you want to generate a new connectionstring:
>> >>
>> >>   public string NewConnectionString()
>> >>   {
>> >>     object _con = null;
>> >>     MSDASC.DataLinks _link =  new MSDASC.DataLinks();
>> >>     _con = _link.PromptNew();
>> >>     if (_con == null) return string.Empty;
>> >>     return ((ADODB.Connection)_con).ConnectionString;
>> >>   }
>> >>
>> >> If you want to modify an existing connectionstring:
>> >>
>> >>   public void ExistingConnection(ref string connectionstring)
>> >>   {
>> >>     MSDASC.DataLinks _link = new MSDASC.DataLinks();
>> >>     ADODB.Connection _con = new ADODB.Connection();
>> >>     _con.ConnectionString = connectionstring;
>> >>     if (_link.PromptEdit((object)_con))
>> >>     {
>> >>       connectionstring = _con.ConnectionString;
>> >>     }
>> >>   }
>> >>
>> >>
>> >> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote
>> >> in
>> >> message news:EB354E06-4073-4185-A65C-3EA56104311D@microsoft.com...
>> >> > Is it possible to invoke this wizard at runtime, using c#, if so
>> >> > how?
>> >>
>> >>
>> >>
>>
>>
>>
Author
6 Jan 2007 3:44 PM
Jack Wasserstein
A thousand thank yous! I will play with it and let you know.

Show quote
"Stephany Young" wrote:

> Stumbled across this by accident while I was looking for something else:
>
> Step 1:
>
>  Add references to:
>
>    Microsoft.Data.ConnectionUI.dll
>    Microsoft.Data.ConnectionUI.Dialog.dll
>
>    You will need to browse for them at C:\Program Files\Microsoft Visual
> Studio 8\Common7\IDE
>    (assuming that your VS2005 is installed to the default location)
>
> Step 2:
>
>   Wherever you want to use it, execute:
>
>     Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog _dialog = new
> Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog();
>
>     Microsoft.Data.ConnectionUI.Dialog.DataSource.AddStandardDataSources(_dialog);
>
>     Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog.Show(_dialog);
>
> You will need to have a play with it to find out how to use it because I
> have no further information than that.
>
>
> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
> message news:3864EA6E-8A50-408D-98F0-7270683E0D73@microsoft.com...
> > Perhaps I posted my question incorrectly, but i am looking to create a
> > connection string to a sql 2005 express database using the wizard at
> > runtime.
> > Do you know how to call that one?
> >
> > "Stephany Young" wrote:
> >
> >> Ummmmmm ... That would be correct. Why would you expect to?
> >>
> >>
> >> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
> >> message news:48D66AA9-EB32-4A10-9ABF-BB44A44DE2CB@microsoft.com...
> >> > Thanks Stephany,
> >> >
> >> > but i dont see any of the .net data providers in the data link dialog
> >> > box
> >> > that pops up?
> >> >
> >> > "Stephany Young" wrote:
> >> >
> >> >> You need to add references to both of these COM libraries:
> >> >>
> >> >>   Microsoft ActiveX Data Objects 2.8 Library
> >> >>   Microsoft OLEDB Service Component 1.0 Type Library
> >> >>
> >> >> If you want to generate a new connectionstring:
> >> >>
> >> >>   public string NewConnectionString()
> >> >>   {
> >> >>     object _con = null;
> >> >>     MSDASC.DataLinks _link =  new MSDASC.DataLinks();
> >> >>     _con = _link.PromptNew();
> >> >>     if (_con == null) return string.Empty;
> >> >>     return ((ADODB.Connection)_con).ConnectionString;
> >> >>   }
> >> >>
> >> >> If you want to modify an existing connectionstring:
> >> >>
> >> >>   public void ExistingConnection(ref string connectionstring)
> >> >>   {
> >> >>     MSDASC.DataLinks _link = new MSDASC.DataLinks();
> >> >>     ADODB.Connection _con = new ADODB.Connection();
> >> >>     _con.ConnectionString = connectionstring;
> >> >>     if (_link.PromptEdit((object)_con))
> >> >>     {
> >> >>       connectionstring = _con.ConnectionString;
> >> >>     }
> >> >>   }
> >> >>
> >> >>
> >> >> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote
> >> >> in
> >> >> message news:EB354E06-4073-4185-A65C-3EA56104311D@microsoft.com...
> >> >> > Is it possible to invoke this wizard at runtime, using c#, if so
> >> >> > how?
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Author
6 Jan 2007 4:10 PM
Jack Wasserstein
Hi Stephany,

Even though I added the Microsoft.Data.ConnectionUI.Dialog.dll as a
reference i am getting this error message when I try to  Run the app. I did
add both of the references. Is there another one that the Dialog one depends
on that i am missing?

Error    1    The type or namespace name 'Dialog' does not exist in the namespace
'Microsoft.Data.ConnectionUI' (are you missing an assembly
reference?)    C:\Program
Files\Invoicible\BillingJWV2\ADOConnection.cs    9    35    Invocible


Show quote
"Stephany Young" wrote:

> Stumbled across this by accident while I was looking for something else:
>
> Step 1:
>
>  Add references to:
>
>    Microsoft.Data.ConnectionUI.dll
>    Microsoft.Data.ConnectionUI.Dialog.dll
>
>    You will need to browse for them at C:\Program Files\Microsoft Visual
> Studio 8\Common7\IDE
>    (assuming that your VS2005 is installed to the default location)
>
> Step 2:
>
>   Wherever you want to use it, execute:
>
>     Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog _dialog = new
> Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog();
>
>     Microsoft.Data.ConnectionUI.Dialog.DataSource.AddStandardDataSources(_dialog);
>
>     Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog.Show(_dialog);
>
> You will need to have a play with it to find out how to use it because I
> have no further information than that.
>
>
> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
> message news:3864EA6E-8A50-408D-98F0-7270683E0D73@microsoft.com...
> > Perhaps I posted my question incorrectly, but i am looking to create a
> > connection string to a sql 2005 express database using the wizard at
> > runtime.
> > Do you know how to call that one?
> >
> > "Stephany Young" wrote:
> >
> >> Ummmmmm ... That would be correct. Why would you expect to?
> >>
> >>
> >> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
> >> message news:48D66AA9-EB32-4A10-9ABF-BB44A44DE2CB@microsoft.com...
> >> > Thanks Stephany,
> >> >
> >> > but i dont see any of the .net data providers in the data link dialog
> >> > box
> >> > that pops up?
> >> >
> >> > "Stephany Young" wrote:
> >> >
> >> >> You need to add references to both of these COM libraries:
> >> >>
> >> >>   Microsoft ActiveX Data Objects 2.8 Library
> >> >>   Microsoft OLEDB Service Component 1.0 Type Library
> >> >>
> >> >> If you want to generate a new connectionstring:
> >> >>
> >> >>   public string NewConnectionString()
> >> >>   {
> >> >>     object _con = null;
> >> >>     MSDASC.DataLinks _link =  new MSDASC.DataLinks();
> >> >>     _con = _link.PromptNew();
> >> >>     if (_con == null) return string.Empty;
> >> >>     return ((ADODB.Connection)_con).ConnectionString;
> >> >>   }
> >> >>
> >> >> If you want to modify an existing connectionstring:
> >> >>
> >> >>   public void ExistingConnection(ref string connectionstring)
> >> >>   {
> >> >>     MSDASC.DataLinks _link = new MSDASC.DataLinks();
> >> >>     ADODB.Connection _con = new ADODB.Connection();
> >> >>     _con.ConnectionString = connectionstring;
> >> >>     if (_link.PromptEdit((object)_con))
> >> >>     {
> >> >>       connectionstring = _con.ConnectionString;
> >> >>     }
> >> >>   }
> >> >>
> >> >>
> >> >> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote
> >> >> in
> >> >> message news:EB354E06-4073-4185-A65C-3EA56104311D@microsoft.com...
> >> >> > Is it possible to invoke this wizard at runtime, using c#, if so
> >> >> > how?
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Author
6 Jan 2007 9:04 PM
Stephany Young
At the time, all I was posting was some information that I stumbled across.

Having now tried it, I find that:

  A reference to Microsoft.Data.ConnectionUI.dll is not necessary - only a
reference to Microsoft.Data.ConnectionUI.Dialog.dll is required.

  The namespace in Microsoft.Data.ConnectionUI.Dialog.dll is actually
Microsoft.Data.ConnectionUI rather than Microsoft.Data.ConnectionUI.Dialog
so amend the 3 lines of code accordingly.

    Microsoft.Data.ConnectionUI.DataConnectionDialog _dialog = new
Microsoft.Data.ConnectionUI.DataConnectionDialog();

    Microsoft.Data.ConnectionUI.DataSource.AddStandardDataSources(_dialog);

    Microsoft.Data.ConnectionUI.DataConnectionDialog.Show(_dialog);

I found that by simply opening the object browser in the IDE and having a
look at the namespaces exposed by the Microsoft.Data.ConnectionUI.Dialog
reference.

I have no need to use this dialog (as yet) and therfore have no need or
inclination to research this further, so you on your own from here.


Show quote
"Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
message news:E5B2145A-F604-47E9-A613-9D12728394A4@microsoft.com...
> Hi Stephany,
>
> Even though I added the Microsoft.Data.ConnectionUI.Dialog.dll as a
> reference i am getting this error message when I try to  Run the app. I
> did
> add both of the references. Is there another one that the Dialog one
> depends
> on that i am missing?
>
> Error 1 The type or namespace name 'Dialog' does not exist in the
> namespace
> 'Microsoft.Data.ConnectionUI' (are you missing an assembly
> reference?) C:\Program
> Files\Invoicible\BillingJWV2\ADOConnection.cs 9 35 Invocible
>
>
> "Stephany Young" wrote:
>
>> Stumbled across this by accident while I was looking for something else:
>>
>> Step 1:
>>
>>  Add references to:
>>
>>    Microsoft.Data.ConnectionUI.dll
>>    Microsoft.Data.ConnectionUI.Dialog.dll
>>
>>    You will need to browse for them at C:\Program Files\Microsoft Visual
>> Studio 8\Common7\IDE
>>    (assuming that your VS2005 is installed to the default location)
>>
>> Step 2:
>>
>>   Wherever you want to use it, execute:
>>
>>     Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog _dialog = new
>> Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog();
>>
>>
>> Microsoft.Data.ConnectionUI.Dialog.DataSource.AddStandardDataSources(_dialog);
>>
>>
>> Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog.Show(_dialog);
>>
>> You will need to have a play with it to find out how to use it because I
>> have no further information than that.
>>
>>
>> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote in
>> message news:3864EA6E-8A50-408D-98F0-7270683E0D73@microsoft.com...
>> > Perhaps I posted my question incorrectly, but i am looking to create a
>> > connection string to a sql 2005 express database using the wizard at
>> > runtime.
>> > Do you know how to call that one?
>> >
>> > "Stephany Young" wrote:
>> >
>> >> Ummmmmm ... That would be correct. Why would you expect to?
>> >>
>> >>
>> >> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com> wrote
>> >> in
>> >> message news:48D66AA9-EB32-4A10-9ABF-BB44A44DE2CB@microsoft.com...
>> >> > Thanks Stephany,
>> >> >
>> >> > but i dont see any of the .net data providers in the data link
>> >> > dialog
>> >> > box
>> >> > that pops up?
>> >> >
>> >> > "Stephany Young" wrote:
>> >> >
>> >> >> You need to add references to both of these COM libraries:
>> >> >>
>> >> >>   Microsoft ActiveX Data Objects 2.8 Library
>> >> >>   Microsoft OLEDB Service Component 1.0 Type Library
>> >> >>
>> >> >> If you want to generate a new connectionstring:
>> >> >>
>> >> >>   public string NewConnectionString()
>> >> >>   {
>> >> >>     object _con = null;
>> >> >>     MSDASC.DataLinks _link =  new MSDASC.DataLinks();
>> >> >>     _con = _link.PromptNew();
>> >> >>     if (_con == null) return string.Empty;
>> >> >>     return ((ADODB.Connection)_con).ConnectionString;
>> >> >>   }
>> >> >>
>> >> >> If you want to modify an existing connectionstring:
>> >> >>
>> >> >>   public void ExistingConnection(ref string connectionstring)
>> >> >>   {
>> >> >>     MSDASC.DataLinks _link = new MSDASC.DataLinks();
>> >> >>     ADODB.Connection _con = new ADODB.Connection();
>> >> >>     _con.ConnectionString = connectionstring;
>> >> >>     if (_link.PromptEdit((object)_con))
>> >> >>     {
>> >> >>       connectionstring = _con.ConnectionString;
>> >> >>     }
>> >> >>   }
>> >> >>
>> >> >>
>> >> >> "Jack Wasserstein" <JackWasserst***@discussions.microsoft.com>
>> >> >> wrote
>> >> >> in
>> >> >> message news:EB354E06-4073-4185-A65C-3EA56104311D@microsoft.com...
>> >> >> > Is it possible to invoke this wizard at runtime, using c#, if so
>> >> >> > how?
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>

AddThis Social Bookmark Button