Hi, I would like to count number of rows in Datatable using Select Method.
My syntax currently looks like this:
Count = datatable.Select(“[ColumnName1] = '”+variable1+“'” and “[ColumnName2]” isnot Nothing).count
There was no validation errors until I added the part after “and”, how do I write the syntax to select rows where a specific column is not empty?
You can use like this
Declare DataRow Array named “drArr”
But how do I write the “condition”?
the condition i input in the select filters is having validation error, not the count part.
Count = datatable.Select(“[ColumnName1] = ‘”+variable1+“’” and “[ColumnName2]” isnot Nothing).CopyToDataTable().Rows.Count
still getting the error “option strict on disallows implicit conversations from ‘string’ to ‘boolean’”
the Count variable should be int32
intCount= datatable.Select(“[ColumnName1] = ‘”+variable1+“’and [ColumnName2] <>'”+string.Empty+“'”).count
already did so.
and “[ColumnName2]” isnot Nothing
this part is giving the error. once it is removed, there isnt any error.
‘string’ is just an empty string variable?
Yes string.Empty means empty value
As @MAHESH1 is also right to apply the
Hi @inyourgravity just another way to solve this problem (and easier) its:
datatable.Rows.Cast(of DataRow).Select(function(row) row(yourColumnIndex).tostring=variable1 AndAlso not string.isnullorwhitespace(row(yourOtherColumnIndex).tostring).Count
Hi, i resolved at this way:
userDT.Select(“Status is not Null”).CopyToDataTable().Rows.Count
DT.Select(“[ColumnName] NOT is Null”)
DT.Select(“[ColumnName] is not Null”)