cancel
Showing results for 
Search instead for 
Did you mean: 

Append Collection Field Type to an existing collection

asilarow
MVP
Hi All, I am trying to build a code stage to add a field type of "Collection" to an existing collection... but I can't find the relevant datatype to select. The below code is not being accepted by the BP Compiler:  If Not Collection.Columns.Contains(Column) Then  Collection.Columns.Add(Column, typeof(DataTable))  End If For Each dr As System.Data.DataRow In Collection.Rows  dr(Column) = Value Next New_Collection = Collection   Getting these error messages: Compiler error at line 3: 'Is' expected. Compiler error at line 3: 'DataTable' is a type and cannot be used as an expression.   Any ideas would be greatly appreciated.  
Andrzej Silarow
2 REPLIES 2

John__Carter
Staff
Staff
Try System.Type.GetType(""System.Data.DataTable"") instead of typeof(DataTable)

asilarow
MVP
Cheers John, That didn't work (it was returning a null value), but it gave me a lead on how to solve it:  Dim a As Type  Dim b As DataTable         b = New DataTable         a = b.GetType() If Not Collection.Columns.Contains(Column) Then  Collection.Columns.Add(Column, a) End If New_Collection = Collection   :-) Regards, Andrzej.
Andrzej Silarow