SSIS script task can't read project variable

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


SSIS script task can't read project variable



In my project.params I have variables such as LampUserName of type string. In my
script task I'm then trying to read them like so:


LampUserName


foreach (var name in new string { "ServerName", "InitialCatalog", "UserName", "Password" }) {
if (!Dts.Variables.Contains(string.Format("$Project::Lamp{0}", name))) {
writer.WriteLine(name);
}
}
string server_name = (string)Dts.Variables["$Project::LampServerName"].Value;
string database = (string)Dts.Variables["$Project::LampInitialCatalog"].Value;
string username = (string)Dts.Variables["$Project::LampUserName"].Value;
string password = (string)Dts.Variables["$Project::LampPassword"].Value;



Every one of those prints out that it doesn't exist and then an exception is thrown. What am I doing wrong?




1 Answer
1



Are you referencing your project parameters from a Script Component within a Data Flow Task? If so, this differs from using a Script Task within the Control Flow. After adding the project parameter in the ReadOnlyVaraiables field, it is accessible as a property of the Variable object.


string database = Variables.DatabaseParameter.ToString();






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

GZQeLsHcCv7urI kcxYEUO7qtVRnDehSKjb,dyjs,8oHodP,619lmjGXUSue3sAw3bY2,dAhloR1 M,LC,NemIa3y3Y
syQhKM8sv goKvumIS F qQv9v45WAlmIz7ShQZSdQWVNo8,iWKTXQCisQ tAbi2gmG,c0o6 qgxGAl,E wtLKYFS

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham