How can I copy from a Collection of DataRows to a DataTable if my collection is empty?
If the collection is not empty, it works with this assign: newPackagesCollection.CopyToDataTable, where newPackagesCollection is a System.Data.EnumerableRowCollection<System.Data.DataRow>. But it fails when the collection has no rows…
And when I try this, it also fails: if(newPackagesCollection.Count > 0,newPackagesCollection.CopyToDataTable, new System.Data.DataTable)
Assign: Can not assign ‘if(newPackagesCollection.Count > 0,newPackagesCollection.CopyToDataTable, new System.Data.DataTable)’ to ‘newPackageDT’.
Error: Assign: Activity ‘1.103: VisualBasicValue’ cannot access this public location reference because it is only valid for activity ‘1.109: VisualBasicValue<EnumerableRowCollection>’. Only the activity which obtained the public location reference is allowed to use it.
What is that?
UPDATE: Now I see it must be inside a Multiple Assign to work…
Suggestion: Try first to assign the result to an array of rows.
Then if the array has more than 0 rows, use the copy to data table function.
That’s the easiest way I found to filter a table and handling the null values.
I sometimes want to do everything in a single line, but VB just does not allow me to do it, lol.
Hope this helps, let me know.