I am using Execute Query activity to run a query on SQL database to get data. I am storing the output into DataTable successfully.
Using For Each Row activity I am looping through the DataTable successfully.
Using Get Row Item activity I am getting the values of particular column (SnippEventID) and storing the output into a Variable with General Value (Variable Type)
If I use Message Box activity in For Each Row I am able to print the output Variable one by one successfully.
But If I want to store all the four SnippEventID values into a Array. How can I do that?
Can I use Add Data Row activity and Build Data Table activity to store all the Variable?
So do I understand this correctly, you want to store all your values in a data table, then return them back as an array? or something like that?
You don’t need to use the Output Data Table for this, and actually it just makes it more complicated.
All you need to do is query your data table that you built to an array of the items. You can use Select for this. To join all the items to one string, then use String.Join()
Try changing the name of the variable from datatable to something else.
If that doesn’t fix it, can you upload the work flow and I can check it on my end.
Ok, I don’t know what’s going on, but I remember seeing this issue before where there is like this bug sometimes and it thinks it’s not a member. I saw the validation error, so I deleted the “.AsEnumerable”, pressed ok to update it, then edited it again and retyped it and error went away. I don’t know if that will help, but here is the file which may let you copy it to yours. Sequence1.xaml (7.6 KB)
Apologies if I misunderstood :
If you want to output each value one at a time as you use the Add Data Row activity, then do so right after the Add Data Row inside the loop.
However, if you want to output each item one at a time outside that loop, then you need to use a For Each instead of a String.Join
For each row in DTOutPut
WriteLine row(0).ToString
If that doesn’t answer your question, can you please explain what you are wanting to do exactly again so maybe I undersrand better. Thanks
I am using Execute Query activity to run a query on SQL database to get data. I am storing the output into DataTable successfully.
Using For Each Row activity I am looping through the DataTable successfully.
Using Get Row Item activity I am getting the values of particular column (SnippEventID) and storing the output into a Variable with General Value (Variable Type)
If I use Message Box activity in For Each Row I am able to print the output Variable one by one successfully.
You code is give me output of all the four SnippEventID’s as shown below
But If I want to store all the four SnippEventID values into a Array of strings or as a Data Table how can i do that.
There are 2 ways to store your values like that, to use a List variable and use the “Add to collection” activity or use a data table with “Add Data Row”. So how you are trying to do this is fine.
It sounds like you want to output each value one by one as you add it to the data table. You can do this inside your “For each row in GetQueryOutput” right next to the Add Data Row, like Write Line SnippEventID, or whatever value is being stored in the data table.