How to convert column values into an array

Hello,

I have a DataTable(Dt1) with 6 Columns. I want to convert “Quantity” Column into an array…

image

So I have tried Dt1.AsEnumerable.Select(Function(a) a.Field(Of String)(“Quant Status”).ToString).ToArray() and it worked.

But, Some columns have an empty rows… as below

image

So I’m getting an Null Exception Error. How can I overcome this issue ? Please Help me.

Hi

Can you try the following expression?

arrStr = dt.AsEnumerable.Select(Function(r) if(r("Quantity") isnot Nothing, r("Quantity").ToString(),"")).ToArray()

Regards,

3 Likes

Thanks a lot @Yoichi

It is working… :pray:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.