Asking for a ConnectionString

  • Thread starter Thread starter Francesco
  • Start date Start date
F

Francesco

Hi guys,
I need a way to ask the user for a ConnectionString for the OleDbConnection
object.
I can see in Visual Studio, that in Server Explorer I can add a data
connection, and a dialog is prompted to let me select the OLEDB provider and
its parameters.
My application should (virtually) be able to connect to any OLEDB database
so, is it possible to use this dialog window in .NET?

If not, how do you usually make the user select the connection string?

TIA
Ciao
Francesco
 
Add two COM library reference to your project:
Microsoft ActiveX Data Objects and Microsoft OLE DB Service Component
Type Library.
Then add the following code:
MSDASC.DataLinks objDataLink = new MSDASC.DataLinksClass();
ADODB.Connection cn = new ADODB.ConnectionClass();
object objCn = (object) cn;
objDataLink.PromptEdit(ref objCn);
Than you'll find in cn.ConnectionString the connection string.
 
Back
Top