Connection String Dialog

S

Steph.

Hi,

How can I display to the user the "Connection String Dialog" (The Dialog to build connection string) in my application ?


Thanks,

Steph.
 
T

Tamir Khason

You can do it with COM Interop. Just figure CLSID (Guid attribute) of this
dialogbox (I thin kthe internal name is DataLinks, but maybe I'm wrong).
Then just use it.
It's bad way, better rewrite it in managed code youself...

--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "


Hi,

How can I display to the user the "Connection String Dialog" (The Dialog to
build connection string) in my application ?


Thanks,

Steph.
 
A

Arild Bakken

You can reference the OLEDB library (Microsoft OLE DB Service Component) in
your project to get easy access to it. Note thought that it will give you
OLEDB connection strings (System.Data.OleDb)- and not System.Data.SqlClient
connection strings (although they are similar - but not quite).


Arild
 
S

Steph.

Thanks but I found exactly what I wanted... I let the solution here for others :

Here is the link to microsoft website : http://support.microsoft.com/default.aspx?scid=kb;EN-US;310083


For Component Object Model (COM) interoperability, you must declare the ADO Connection object as ADODB._Connection and cast the generic object that the data link returns to an ADODB._Connection.
Start Visual Studio .NET, and then create a new Visual C# Windows Application project. Form1 is added to the project by default.

From the Project menu, click Add Reference.
On the COM tab, select the following references:
Microsoft ActiveX Data Objects 2.7
Microsoft OLEDB Service Component 1.0 Type Library


If you are prompted to have a wrapper generated for you, click Yes.
Add a Button control to Form1.
Add the following code to the Button1_Click event:

MSDASC.DataLinks mydlg = new MSDASC.DataLinks();
ADODB._Connection ADOcon;

//Cast the generic object that PromptNew returns to an ADODB._Connection.
ADOcon = (ADODB._Connection) mydlg.PromptNew();

ADOcon.Open("","","",0);

if (ADOcon.State == 1) {
MessageBox.Show("Connection Opened");
ADOcon.Close();
}
else {
MessageBox.Show("Connection Failed");
}


That's it, Thanks Microsoft.

Steph.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top