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
Hello,

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)
SEE:
http://support.microsoft.com:80/supp.../Q225/1/32.asp
*/
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?
//connection.

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

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


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.