Search code examples
vb.netdatatablelinq-expressionsdatacolumn

Column.Expression = String(1)


In my DataTable I have one column that is :

With colA
            .DataType = System.Type.GetType("System.String")
            .ColumnName = "colA"
End With

I have an array of strings named strTest and strTest(6) is "00".

I try to do that :

colA.Expression = strTest(6)

No error, but in place of set the value to "00" it writes "0".

Where is my mistake ?

Thanks :)


Solution

  • It's evaluating your expression as a constant number. Instead, use single quotes and it'll know its a string.:

    colA.Expression = "'" & strTest(6) & "'"