Input string is not in correct format

Hi i have a dataTable , it has column named Order Total.
i am reading the data using enumerable as : dt_OutData.AsEnumerable.Where(Function(a) Convert.ToInt32(a(“Order Total”).ToString.Trim) > 500).CopyToDataTable

I am getting error as input string is not in correct format.

Can some one help me out, what is this error and for what reason it will come and how to solve it.

hi, can you share the screenshot of the datatable. thanks

Please find below ss:

you’re converting a column with Decimal values as Integer. Try to use “Convert.ToDecimal” instead of Convert.ToInt32 and see if it works

Hi @kennbalobalo I tried using convert.todecimal also still i have the same issue.

hi, I tried it and it’s filtering:

here’s the code:
FilterDataTable.xaml (9.8 KB)

here’s the expression: dt_OutData.AsEnumerable.Where(Function(a) Convert.ToDecimal(a(“Order Total”).ToString.Trim) > 500).CopyToDataTable

Hi @kennbalobalo, Thanks for your reply…!!

I too had build the same logic as you sent. and reason it got failed because the excel sheet has a pivot table in it. So it was failing.
After going through code you sent that clarifies the reason for failure.

Thanks @kennbalobalo for your help.

Glad to help. Kindly mark it as solution so it can also help others. Thanks

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