How to Convert the Object into String in datatable?

For my project, I needed to filter a DataTable with a column named “NotFound,” which had an initial data type of “object.” To address this, I utilized the Read DataTable activity and implemented a For Each Row loop. However, despite these efforts, the column data type continues to be registered as “object.”

Can u elaborate more about the same

Hi @chandrakala.productanalys

Instead the For each row loop you can place a log message and write as

CurrentRow("NotFound").ToString

Hope this may help you

Thanks,
Srini

Hi @chandrakala.productanalys ,

We would need to create a new Datatable with the Required Column Data types and then populate the Datatable by adding the rows from the Original Datatable using Add Data Row activity or could also approach with a Linq.

i just want to filter the column=“Not found” in datatable.The column is object datatype in datatable.i tried to convert data type into string.so i created a new dt and add data row.Still it showing the column type in object data type only.

Hi @chandrakala.productanalys

inside the for each row activity you can try this way

str = CurrentRow("Not found").ToString

Still showing the column type into object only.
dt=dt.AsEnumerable.Where(Function(r) System.Text.RegularExpressions.Regex.IsMatch(r(“Protection Status”).ToString(),“Not Found”)).CopyToDataTable

i want to get rows=“Not found” in datatable.

@chandrakala.productanalys ,

Could we modify the Expression to the below and check :

dt=dt.AsEnumerable.Where(Function(r) r("Protection Status").ToString.Trim.ToLower.Equals("not found")).CopyToDataTable

You can try this way to get only the not found rows in data table

dt = (From row In dt.AsEnumerable()
      Where row.Field(Of String)("Protection Status").Trim().ToLower() = "not found"
      Select row).CopyToDataTable()

@chandrakala.productanalys

Hi @chandrakala.productanalys

Try this

dtFiltered = dt.AsEnumerable().Where(Function(r) r("Protection Status").ToString() = "Not Found").CopyToDataTable()