How to handle this

i got some data in dt and now i am filtering it out as per the status
dt = (from dr as datarow in DB_REsult where dr.item(“PROCESS_STATUS”).tostring.equals(“ERROR”) select dr).copytodatatable

but sometime there is no data that matches the condition how to handle this as its breaking

@manoj_verma1

Remove CopyToDataTable at the end assign output to Array of DataRows. So that it won’t throw any error. After this you can check row count. If is greater than 0 then matching rows found else not.

1 Like

Screenshot_4
get this error @lakshman

dbfiltered_error is system.data.datarow

@manoj_verma1

Try below expression.

      DBFiltered_Error = DB_REsult.Select("PROCESS_STATUS = 'ERROR'")

@lakshman how to check that variable has no data row s ```
DBFiltered_Error

@manoj_verma1

            DBFiltered_Error.Count > 0

if its >0 then i want to generate a excel so how get all those in dt

so i can use the above condition

i got some data in dt and now i am filtering it out as per the status
dt = (from dr as datarow in DB_REsult where dr.item(“PROCESS_STATUS”).tostring.equals(“ERROR”) select dr).copytodatatable

@manoj_verma1

     dt = DBFiltered_Error.CopyToDataTable

And then use Write Range activity and pass above output DataTable dt to write into the excel file.

Hi @manoj_verma1

Try this expression

If(DB_REsult.AsEnumerable.where(Function(dr) dr.item(“PROCESS_STATUS”).tostring.equals(“ERROR”)).Count.Equals(0),
_
DB_REsult.Clone,
_
DB_REsult.AsEnumerable.Where(Function(dr) dr.item(“PROCESS_STATUS”).tostring.equals(“ERROR”)).CopyToDataTable)

Hi @manoj_verma1 ,

The Handling of the Exception is Explained in the below Post :

1 Like

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