I've two nested foreach loop containers. Each are looping on different resultsets. I've a script task, within the inner foreach loop container, in which I need to be able to acccess values of current row of both the loops. One way of doing it is using variable mappings on both the loops, but is there a way to access current row from within the script? any ideas?
You can access variables mapped in loop containers in script task via Variables
property of the Dts
object if you add this variables to ReadOnlyVariables
or ReadWriteVariables
lists in the Script Task Editor.
Map current row of each loop to variable and then access this variables in script task. Isn't this enough?
Example:
string fileName = (string) Dts.Variables["FileName"].Value;
You can read more here: http://msdn.microsoft.com/en-us/library/ms135941.aspx
Update:
You can map whole row to variable at once. Use Object
as variable type and set Index = -1
in Variable mappings in Foreach loop.You should receive enumerator, which type is related to enumerated collection.