I have a Data Table created which has the last column as a List of Strings.
Then I fill the Data Table with some data, including the lists of strings, but then, I am trying to access the data and I cannot understand how do I iterate through the lists of strings in each row:
(had to combine 2 screenshots into one, cannot upload more than one yet.)
I’ve tried to create a dataTable with the a
String in one of its columns but I was unable to add any data to it directly in the build table or with add data row activity I think this problem needs more investigations
As the error message says, the compiler doesn’t know that what you have in the sixth column (row.item(5)) is an array of strings, since the method that gets the data from the DataTable row says it’s an Object.
There are two ways of fixing your problem.
The first one is to tell the compiler to treat that object as an array of strings, since you know for sure that is what you put into that cell. (Note that this will blow up with an error if the Object is not actually an array of strings or if it isn’t actually there - it’s Nothing/null. Also note that an empty list will work fine, but it shouldn’t be confused with a null)
Forcefully “telling” the compiler what’s the data type of a variable/expression is called type casting. In your case you could use TryCast or DirectCast (more about them here: https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/trycast-operator ) so instead of
row.Item(5) you could say
This is how it would look (I also added an intermediate variable catsList of type String):
The second option, and the one I actually recommend is to access the array value through the Field() method instead of the Item() method, like this:
Thanks a lot for the answer. Seems like it’s the answer to the original question and my error went away, though now I get a runtime error, which is:
Source: For Each
Message: Object reference not set to an instance of an object.
Exception Type: System.NullReferenceException
Below is a link to the sample workflow, I am trying to get to work. I appreciate if you can help me fix it.
https:// drive. google. com/file/d/15QQQsUz07c4LJnTkFNjDt6uv3hnwD6qY/view?usp=sharing
(please delete the spaces in the link, I cannot attach files nor post proper links yet :S)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.