This Blog entry discusses how to obtain a connection string from users using the Data Link Properties screen.
To obtain 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;
Call the PromptNew method of the datalink and assign it to the ADODB connection. This will return an ADODB connection object.
Example:
connection = (ADODB._Connection)dataLinks.PromptNew();
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 = (ADODB._Connection)dataLinks.PromptNew();
return connection.ConnectionString.ToString();
No comments:
Post a Comment