Linq Query -- Help

Hi everyone,

I was using one function that is removing all particular character from DT, but when that particular column is empty , i am getting this error ,
Please help.
image

and the function which i am using:-
(From r In mergedtextfileop.AsEnumerable
Let ra = r.ItemArray.Select(Function (x) x.ToString.Trim.Replace(“%%”,“,”)).toArray()
Select correctData.Rows.Add(ra)).CopyToDataTable()

because my column is empty i am getting this error,
Please help me to modify this function accordingly.

1 Like

Hi @Anjali_Rani

Hope the below helps you…

(From r In mergedtextfileop.AsEnumerable
Let ra = r.ItemArray.Select(Function (x) if(not string.isNullOrEmpty(Convert.ToString(x).Trim), x.ToString.Trim.Replace("%%",","), x)).toArray()
Select correctData.Rows.Add(ra)).CopyToDataTable()

Thanks
#nK

2 Likes

Thank you very much :slight_smile:

1 Like

Most welcome @Anjali_Rani :slight_smile:

1 Like

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