Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Script task - how to do computations on variables?

Author  Topic 

tybaltzeke
Starting Member

28 Posts

Posted - 2010-09-28 : 11:22:33
In a script task, HOW DO YOU perform computations on ReadWrite VARIABLES? If you try to simply add a number to a variable (see the CODE SAMPLE below, note that all user::variable references are valid) you get the error message below. Are there Add, subtract and multiply methods for the DTS.variables object? How do you invoke them? I am a senior SSIS person but somewhat of a novice at C# programming.

ERROR MESSAGE
Error 1 Operator '+' cannot be applied to operands of type 'object' and 'int'



CODE SAMPLE
public void Main()
{
// TODO: Add your code here
Dts.TaskResult = (int)ScriptResults.Success;
Dts.Variables["User::OutRowsInserted"].Value =
Dts.Variables["User::InRowsInserted"].Value + 3;

}
}
}
   

- Advertisement -