By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,749 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,749 IT Pros & Developers. It's quick & easy.

Create a MS SQL Server Connection DataLink Properties Window

P: n/a

I'm trying to create a Data Links Property window that behaves just like
the dialog box in Visual Studio .Net for MS Sql Server connections. I've
found a lot of examples that use DataLinks classes from "Microsoft OLE DB
Service Component 1.0 Type Library" and the Connection object from ADODB.
However, when setting the connection string using these classes the
connection string always returns a really basic connection string with no
additional params.

The connection string I'm currently receiving is:
Provider=SQLOLEDB.1;Password=mypass;Persist Security Info=True;User
ID=sa;Initial Catalog=Northwind;Data Source=(local)

I would like a connection string that looks more like:
packet size=4096;user id=sa;data source=(local);persist security
info=True;initial catalog=NorthWind;password=mypass

It seems like the DataLink / Connection option isn't returning all the
parameters / properties that can be set in the "All" tab of the Data Link
Properties window.

What am I missing...

The Code:

private void launchDataPromptEdit_Click(object sender, System.EventArgs e)
Reference DataLinks
NOTE: Reference
C:\Program Files\Common Files\System\Ole DB\OLEDB32.DLL
(Was MSDASC.dll)
MSDASC.DataLinks dataLinks = new MSDASC.DataLinksClass();
//note that a reference to:
// c:\Program Files\Microsoft.NET\Primary Interop Assemblies\adodb.dll
//is also required to read the ADODB._Connection result
ADODB._Connection connection;
//are we editing an existing connect string or getting a new one?

if(connStr.Text == string.Empty)
// get a new connection string
//Prompt user for new connect string

connection = (ADODB._Connection)dataLinks.PromptNew();
//read result
connStr.Text =
catch(Exception ex)
// edit connection string
connection=new ADODB.ConnectionClass();
//set local COM compatible data type
object oConnection=connection;
//prompt user to edit the given connect string
if((bool)dataLinks.PromptEdit(ref oConnection))
catch(Exception ex)

Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.