How to select from DataTable with specific column Value is Not Null?

Hi,

I tried to select DataRow which particular column content is Not Null by using the below statement, but it didn’t work.

DataTable.Select(“[ColumnName] is not null”).CopyToDataTable

Is the statement incorrect or there’s other way to achieve it?

Thanks in advance

@opas1216 Can you Check this Statement :
DT.AsEnumerable.Where(Function(x)String.IsNullOrEmpty(x(“ColName”).ToString) or String.IsNullOrWhiteSpace(x(“ColName”).ToString)).CopyToDataTable

Provide your Column Name in place ColName

2 Likes

Hi
Thank you for your reply

I’ll try it and see whether it works.

But is your statement is searching the Column which is Null?
I’m not sure am I understand it correctly, is it LinQ?

@opas1216 Ohh Wait, I’ll need to use a Not Operation in there. It results in Filtering out only empty rows, you need the opposite :sweat_smile: Try this :

DT.AsEnumerable.Where(Function(x)Not (String.IsNullOrEmpty(x(“ColName”).ToString) or String.IsNullOrWhiteSpace(x(“ColName”).ToString))).CopyToDataTable

4 Likes

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