In the switching world developer often needs to toggle between connection managers and wish the code operates as its expected.However, the execution engine is yet to be smart enough to undertake the difference.
Connection Manager Type | Connection Manager Name |
---|---|
ADO | ADO Connection Manager |
MSOLAP90 | Analysis Services Connection Manager |
EXCEL | Excel Connection Manager |
FTP | FTP Connection Manager |
HTTP | HTTP Connection Manager |
ODBC | ODBC Connection Manager |
OLEDB | OLE DB Connection Manager |
For those pin point here a code that worked for me and happy if works for you as well.
FOR ADO.NET Connection Manager
SqlConnection sConnection = new SqlConnection();
sConnection = (SqlConnection)(Dts.Connections["MyConnectionManagerADO.NETName"].AcquireConnection(Dts.Transaction) as SqlConnection);
var connection = sConnection.ConnectionString.ToString()
FOR OLEDB Connection Manager
var oConnection = Dts.Connections["MyConnectionManagerOLEDBName"].ConnectionString.ToString().Trim();
oConnection = oConnection.Replace("Provider=SQLNCLI10.1;", "").Replace("Provider=SQLNCLI11;", "").Replace("Provider=SQLNCLI11.1;", "").Replace("Auto Translate=False;", "");
Second method return invalid password
ReplyDeleteAgree with Raj, 2nd approach with .ConnectionString -- this string removes the password. So going directly to ConnectionString only works if using Windows Auth (hence no password needed)
ReplyDelete