Can SSIS Variables store ArrayList
I want to store the following to variable but not sure if possible. Below are sample code that i want to accomplish.
PLEASE HELP.
public class Person
{
public int PersonID {get; set}
public string PersonName { get; set}
}
//loop to build the arraylist, i didnot complete the Syntax
while (read)
(
ArrayList personList = new ArrayList();
ArrayList.Add(new Person{PersonID =myID, PersonName = myName} );
}
Dts.Variables["PersonObject"].value = personList;
Jim Pan
July 6th, 2012 10:33am
You must be able to achieve this but you need to use the SSIS' Object variable as shown in this thread:
http://social.msdn.microsoft.com/Forums/en/sqlintegrationservices/thread/9432f740-14fc-48fd-b137-6a94e390b3c0Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
July 6th, 2012 10:45am
I will try and post the finding. Thanks.Jim Pan
July 6th, 2012 10:52am
Hi,
In addition to
ArthurZ you can also use below example as well.
Name DataType
Collection object
2- add a Script Task, set User::Collection as ReadWriteVariables
3- choose language as Visual C#, and write this code in main() method:
public void Main()
{
System.Collections.ArrayList arr = new System.Collections.ArrayList();
arr.Add("the first item");
arr.Add("the second item");
arr.Add("the third item");
Dts.Variables["User::Collection"].Value = arr;
Dts.TaskResult = (int)ScriptResults.Success;
}
4- save and build the Script.madhur_ms
Free Windows Admin Tool Kit Click here and download it now
July 9th, 2012 12:57pm
could you please tell about the need to store variables in an arraylist, i guess depending on the requirement there might be some other easy way to solve the scenario.
http://social.msdn.microsoft.com/Forums/en/sqlintegrationservices/thread/9432f740-14fc-48fd-b137-6a94e390b3c0
regards
joon
July 9th, 2012 1:20pm
Hi,
In addition to
ArthurZ you can also use below example as well.
Name DataType
Collection object
2- add a Script Task, set User::Collection as ReadWriteVariables
3- choose language as Visual C#, and write this code in main() method:
public void Main()
{
System.Collections.ArrayList arr = new System.Collections.ArrayList();
arr.Add("the first item");
arr.Add("the second item");
arr.Add("the third item");
Dts.Variables["User::Collection"].Value = arr;
Dts.TaskResult = (int)ScriptResults.Success;
}
4- save and build the Script.
madhur_ms
@Joon84: It always worth to bring the link that you copied information form as reference !!!
http://www.rad.pasfu.com/index.php?/archives/18-Foreach-Loop-based-on-Variable-SSIS.html
@wpan: yes you can use object variable as I mentioned in above blog post, please let us know if you have any problemhttp://www.rad.pasfu.com
Free Windows Admin Tool Kit Click here and download it now
July 9th, 2012 11:32pm