Reputation: 1102
I am developing a custom SSIS task. It exposes a few properties which are to be defined by the user. For now I have not implemented the GUI so I set the parameters in the task properties window.
Now say I have a property called LastName, and I have an SSIS Variable User::LastName. When I put User::LastName into the properties, it just passes the string: "User::LastName" instead of evaluating the value of the string....
How can I have it pass the value of the string?
Upvotes: 1
Views: 2018
Reputation: 1102
I have found a solution.
Define the variable LastName in the package given it a value, say "John". Then in the custom task properties, click on Expressions, and click on the [...]. There under property select LastName property (or whatever name is defined in the custom tasks) and then under experssion click on [...]. By expanding Variables you get a list of all your variables. You can then drag drop a wanted variable into the Expression input box under. Evaluate expression button enables to verify it contains the wanted value. Then click OK and OK... Building the SSIS project then does the trick...
Upvotes: 1
Reputation: 61239
As you've determined st that point, you've passed in the name of the variable to the component. You will need to evaluate the value of the object in the Dts.Variables collection, cast to the appropriate type.
I think you're looking at either having two variables in your component, one to pass the variable name back and forth and one to hold the actual value. You could probably make a struct that handles both of those but I'm willing to freehand that in an answer ;)
// Retrieve a single variable.
// Assumes this.LastNameVariable is a string with value of User::LastName
IDTSVariables100 variables = null;
VariableDispenser.LockOneForRead(this.LastNameVariable, ref variables);
this.LastName = variables[0].Value.ToString();
variables.Unlock();
Upvotes: 1