Reputation: 10385
In my SSIS package I have a package level connection manager named LAMP that I now want to access in my Script Task. I tried to use this to get the connection string:
var conn = Dts.Connections["LAMP"].AcquireConnection(Dts.Transaction) as string;
but that comes back with an empty string. Is it possible to pull a package level connection string?
It's an OLEDB connection manager, using the Native OLE DB\SQL Server Native Client 11.0
provider.
Upvotes: 1
Views: 11418
Reputation: 3957
Frankly, you are doing it backwards. Create a variable to store the connection string. Then assign the connection string as a ConnectionString expression to the Lamp connection manager while also reading the connection string variable from the script task editor. The following steps should help:
In your code:
string strConnectionStringLamp = (string) Dts.Variables["ConnectionStringLamp"].Value;
Upvotes: 1