Database Reference
In-Depth Information
Variable Syntax in Code
Declaring read-only or read-write variables is a similar experience whether you're us-
ing the Script task or the Script component. However, the syntax to address these vari-
ables in code is different depending on the tool you're using. As shown in Listing 3-4 ,
SSIS variables within a Script task instance are addressed by using a string indexer to
specify the name of the variable.
Listing 3-4 . Script Task Variable Syntax
public void main()
{
// Get the current RunID
int runID
= int.Parse(Dts.Variables["RunID"].Value.ToString());
// Set the ClientID
Dts.Variables["ClientID"].Value
= ETL.GetClientID(runID);
Dts.TaskResult = (int)ScriptResults.Success;
}
When using an instance of the Script component, the syntax is noticeably different.
Rather than using an indexer to read from or write to the referenced SSIS variables,
you can use the Variables.<Variable Name> syntax as shown in Listing 3-5 :
Listing 3-5 . Script Component Variable Syntax
public override void Input0_ProcessInputRow(Input0Buffer
Row)
{
// Push the SSIS variable ClientName to the value
in the current row
Row.ClientName = Variables.ClientName;
}
 
 
 
 
Search WWH ::




Custom Search