This Blog entry discusses how to edit a connection string using the Data Link Properties screen.
To edit a database connection string through the Data Link Properties screen, you would need the following references:
- ADODB
- MSDASC
Declare an object of type MSDASC.DataLinks and assign it a new instance.
Example:
MSDASC.DataLinks dataLink = new MSDASC.DataLinksClass();
Declare an ADODB Connection object.
Example:
ADODB._Connection connection;
Set the connection object to a new ConnectionClass.
Example:
connection = new ADODB.ConnectionClass();
Set the connectionString property of the connection to the connectionString to be edited.
Example:
connection.ConnectionString = connectionString;
Call the PromptEdit method of the datalink and assign it to the ADODB connection and pass the connection as a reference parameter.
Example:
dataLink.PromptEdit(ref oConnection)
Access the connection string property of the connection object
return connection.ConnectionString.ToString();
Example Code:
MSDASC.DataLinks dataLinks = new MSDASC.DataLinksClass();
ADODB._Connection connection;
connection = new ADODB.ConnectionClass();
connection.ConnectionString = connectionString;
dataLink.PromptEdit(ref oConnection)
return connection.ConnectionString.ToString();
No comments:
Post a Comment