locked
Custom Task - Variable Value Assignment RRS feed

  • Question

  • Hi All,

    I am trying to create an custom control flow task through C#. In that I want to assign some value to a Variable. Can you please share some sample code to do it.

    Thanks,

    Naveen T


    Naveen Kumar

    Friday, July 13, 2012 12:45 PM

Answers

  • Hi Kumar,

    The value of a custom variable can be a literal or an expression:
    1. If you want the variable to contain a literal value, set the value of its Value property.
    2. If you want the variable to contain an expression, so that you can use the results of the expression as its value, set the EvaluateAsExpression property of the variable to true, and provide an expression in the Expression property. At run time, the expression is evaluated, and the result of the expression is used as the value of the variable.

    For more information about it and coding example, please see:
    Working with Variables Programmatically: http://msdn.microsoft.com/en-us/library/ms136082.aspx

    Thanks,
    Eileen

    • Marked as answer by Eileen Zhao Thursday, July 26, 2012 7:21 AM
    Thursday, July 19, 2012 8:10 AM

All replies

  • Should be what you need here:

    http://www.thejoyofcode.com/SSIS_Set_Variable_Custom_Task.aspx


    Chuck Pedretti | Magenic – North Region | magenic.com

    • Proposed as answer by irusul Friday, July 13, 2012 1:09 PM
    Friday, July 13, 2012 12:54 PM
  • Hi Kumar,

    The value of a custom variable can be a literal or an expression:
    1. If you want the variable to contain a literal value, set the value of its Value property.
    2. If you want the variable to contain an expression, so that you can use the results of the expression as its value, set the EvaluateAsExpression property of the variable to true, and provide an expression in the Expression property. At run time, the expression is evaluated, and the result of the expression is used as the value of the variable.

    For more information about it and coding example, please see:
    Working with Variables Programmatically: http://msdn.microsoft.com/en-us/library/ms136082.aspx

    Thanks,
    Eileen

    • Marked as answer by Eileen Zhao Thursday, July 26, 2012 7:21 AM
    Thursday, July 19, 2012 8:10 AM