Convert problem to Data.DataTable

datatable

#1

Hi.
i’ve used a for each row , because i want to read some values to get the max and the min value(Prices)
But i get this error message ?
Compiler error encoutered processing expression “result”.
Option Stict Ib dusallows implicit conversions from ‘System.Collections.Generric.IEnumerable’(Of objet) to 'System.Data.DataTable’
Any help please?
Thank u.


#2

You’re probably using a generic For Each which needs to have the type property set to System.Data.DataRow.
There are lots of examples around: https://forum.uipath.com/search?q=loop%20datatable%20for%20each


#3

Hi there Hamza Soufiane,
As Badita has stated, you are likely utilising For Each when iterating, which is causing the disallowed conversion error.
If you specifically require the use of For Each then follow his advice, otherwise I would use For Each Row.

I have created a VERY basic component, which appears to complete what you require.

Thanks in advance!

forEachExample.xaml (17.1 KB)


#4

Thank u.
But please there is a simple methode to get the max value from a table?


#5

You can use Lambda expressions.
For example:

YourDataTable.AsEnumerable().Max(Function(res) res.Field(Of Int32)("Column0"))