Anyone know about how to create an expression task in c# to generate SSIS expression task?
Thank you.
I know about PrecedenceConstraint.
See my code:
Executable exe1 = pkg.Executables.Add("STOCK:SQLTask");
TaskHost TKHSQLHostMySQLTask = (TaskHost)exe1;
TKHSQLHostMySQLTask.Name = "my sql";
ExecuteSQLTask MySQLTask = (ExecuteSQLTask)TKHSQLHostMySQLTask.InnerObject;
//creating Execute SQL Task
MySQLTask.Connection = "sourcecon";
MySQLTask.SqlStatementSource = "select deptno from dbo.dept";
MySQLTask.SqlStatementSourceType = SqlStatementSourceType.DirectInput;
MySQLTask.BypassPrepare = false;
Executable exe2 = pkg.Executables.Add("STOCK:SQLTask");
TaskHost TKHSQLHostMySQLTask1 = (TaskHost)exe2;
ExecuteSQLTask MySQLTask1 = (ExecuteSQLTask)TKHSQLHostMySQLTask1.InnerObject;
//creating Execute SQL Task
MySQLTask1.Connection = "sourcecon";
MySQLTask1.SqlStatementSource = "select deptno from dbo.dept where deptname=?";
MySQLTask1.SqlStatementSourceType = SqlStatementSourceType.DirectInput;
MySQLTask1.BypassPrepare = false;
// Add input parameter binding
MySQLTask1.ParameterBindings.Add();
IDTSParameterBinding parameterBinding = MySQLTask1.ParameterBindings.GetBinding(0);
parameterBinding.DtsVariableName = "[User::Dname]";
parameterBinding.ParameterDirection = ParameterDirections.Input;
//parameterBinding.DataType = (int)OleDBDataTypes.VARCHAR;
parameterBinding.ParameterName = "0";
parameterBinding.ParameterSize = 255;
PrecedenceConstraint pc = pkg.PrecedenceConstraints.Add((Executable)exe1, (Executable)exe2);
pc.EvalOp = DTSPrecedenceEvalOp.ExpressionAndConstraint;
pc.Expression ="[User::myVar]>0";
//how to add Expression task ?