|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, March 10, 2011 1:45 PM
Points: 11,
Visits: 46
|
|
Hi,
I'm using ForEach Loop container and selected "ForEach From Variable Enumerator" option. I created a variable of System.Object(User::Collection) and selected the "User::Collection" for Variable dropdown in Enumertaor configuration.
I have a script task that populates the "User::Collection" variable. The code is listed below
Public Sub Main() ' ' Add your code here ' Dim arr As New ArrayList arr.Add("D:\Tests\a.txt") arr.Add("D:\Tests\b.txt") Dts.Variables("User::Collection").Value = arr
Dts.TaskResult = Dts.Results.Success End Sub
The script task that populates the collection is connected to the foreach loop. In the foreach loop, there is a script task that reads the indexed value and displaying the value. I'm able to read only the first value and not all the other values in the collection. Any thoughts?
Thanks in Advance
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 9:57 PM
Points: 32,893,
Visits: 26,771
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, March 10, 2011 1:45 PM
Points: 11,
Visits: 46
|
|
Hi,
I'm trying to use "ForEach From Variable" Enumerator. In the foreach loop, I'm able to read only the first item from the collection.
How can I access all the items in the collection?
Thanks,
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Friday, May 03, 2013 5:35 AM
Points: 803,
Visits: 2,122
|
|
Like Jeff, I'm not sure what it is you are trying to do.
what is the purpose of the package? Is it to parse through a list of files?, to loop through a dataset?
_________________________________________________________________________ SSC Guide to Posting and Best Practices
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, March 26, 2013 3:14 AM
Points: 345,
Visits: 503
|
|
Works fine for me.
How are you trying to access the variable from the object? Did you define another variable and mapped in for each loop?
-- Sabya
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, March 26, 2013 3:14 AM
Points: 345,
Visits: 503
|
|
The only additional thing I did was to define a variable user::fileJustFound (string).
On for each loop container -> variable mapping -> mapped user::fileJustFound as 0 (the only one variable)
Then used a simple file system task to delete the file with name = user::fileJustFound....
It looped through successfully and deleted files. Wondering if you are missing this part of mapping the variable appropriately.
-- Sabya
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Friday, May 03, 2013 5:35 AM
Points: 803,
Visits: 2,122
|
|
sabyasm (12/22/2009)
The only additional thing I did was to define a variable user::fileJustFound (string).
On for each loop container -> variable mapping -> mapped user::fileJustFound as 0 (the only one variable)
Then used a simple file system task to delete the file with name = user::fileJustFound....
It looped through successfully and deleted files. Wondering if you are missing this part of mapping the variable appropriately.
I would ask whats the point of using the Script Task if its a simple File directory parser, why not simply use the built in file Enumerator thats provided in the Task.
_________________________________________________________________________ SSC Guide to Posting and Best Practices
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, March 26, 2013 3:14 AM
Points: 345,
Visits: 503
|
|
what is the purpose of the package? Is it to parse through a list of files?, to loop through a dataset?
You already asked ...
I was more curious and tried to help on why it wasn't working - rather than why he is using this approach..
-- Sabya
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Friday, May 03, 2013 5:35 AM
Points: 803,
Visits: 2,122
|
|
sabyasm (12/22/2009)
what is the purpose of the package? Is it to parse through a list of files?, to loop through a dataset?
You already asked ...
I was more curious and tried to help on why it wasn't working - rather than why he is using this approach..
Touche....
_________________________________________________________________________ SSC Guide to Posting and Best Practices
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, March 10, 2011 1:45 PM
Points: 11,
Visits: 46
|
|
Jason Lees-299789 (12/22/2009) Like Jeff, I'm not sure what it is you are trying to do.
what is the purpose of the package? Is it to parse through a list of files?, to loop through a dataset?
I need to get a list of Names from the database and use the list it in multiple tasks of the package. So I'm getting the names from the database and storing them in to a array list. The array list is stored in to a variable of System.Object. This will avoid the trips to the database to get the names every time I need them.
I'm trying to figure out how to read the names from the Variable(User::Collection) using the ForEach From Variable Enumerator.
Hope this helps.
|
|
|
|