How to check if a column in a data table has any values or not

datatable
studio

#1

How to check if a column in a data table has any values or not. I have tried the

  • dt.Select(“colname is null”)

  • Any() method

Need to check if the column has any values or is it empty before proceeding for each loop


How to check if a particular column is empty in DataTable (Without using For Each Row)?
#2

dt.Select(“colname is null OR TRIM(colname)=''”)


Question related to DBNull
#3

Hi @PD2
Dt.Select("columnname <> '' or columnname is not null")
LINQ
Dt.Rows.Cast(Of DataRow)().Where(Function(row) Not (row("columnname") Is DBNull.Value Or Convert.Tostring(row("columnname")).Trim.Equals(""))).CopyToDataTable()

Or

variable4.AsEnumerable.Where(Function(row) row("columnname") is DBNull.Value or Convert.Tostring(row("columnname")).Trim = "").CopyToDataTable

Regards,
Arivu


#4

Thank you @vvaidya and @arivu96 for the prompt help. It sure helped, really appreciate it.


#5

very good solution, thanks


#6

Where should I put these expressions? I can’t place them into decision activity because they are not Boolean