Dear friends
if i use String.IsNullOrEmpty(Row(“Status”).Tostring) in condition
where my column name status
in my database multiple rows but some starting row have status ok and after that rows everyone is blank previously it’s working but now not work
try the following condition:
isNothing(Row("Status")) OrElse String.IsNullOrEmpty(Row("Status").Tostring.Trim)
and detect empty rows
Hey @Simple_Works ,
If your original condition (String.IsNullOrEmpty(Row("Status").ToString)
) is not working as expected, here are a few alternative solutions you can try:
Solution 1: Use IsDBNull
Check
Sometimes, data from a database can have DBNull
values. To handle that, you can combine IsDBNull
with String.IsNullOrWhiteSpace
:
If IsDBNull(Row("Status")) OrElse String.IsNullOrWhiteSpace(Row("Status").ToString)
Solution 2: Use String.IsNullOrWhiteSpace
Instead
If the issue is due to whitespace characters (like spaces or tabs), try this:
If String.IsNullOrWhiteSpace(Row("Status").ToString)
This checks for null
, empty strings, and strings that only contain whitespace.
Solution 3: Check for Nothing
If your row might be Nothing
, add a check for that:
If Row("Status") Is Nothing OrElse String.IsNullOrEmpty(Row("Status").ToString)
Solution 4: Use Trim
to Remove Extra Spaces
Sometimes, there could be leading or trailing spaces. Use Trim()
to clean up the value:
If String.IsNullOrEmpty(Row("Status").ToString.Trim)
Solution 5: Combine All Checks for Robustness
For a more comprehensive check:
If IsDBNull(Row("Status")) OrElse Row("Status") Is Nothing OrElse String.IsNullOrWhiteSpace(Row("Status").ToString.Trim)
Explanation:
IsDBNull
handles cases where the database column hasDBNull
values.String.IsNullOrWhiteSpace
coversnull
, empty strings, and strings with only spaces.Trim()
removes any extra spaces that may cause unexpected behavior.
Try these solutions and see which one works for your specific scenario. Let me know if you need more help!
Best,
Chaitanya
Thanks
for the reply
now it’s working
Please mark this as the solution if it helps! @Simple_Works
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.