DataTable Compute Method

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

There are 3 DaTables in my DataSet, which 1 is the Master and 2 are
Children. I've set the relations and everything is working fine. But when I
try to use the Compute method I receive a strange error and I can't find the
solution.

dtsMovES.Tables("MovES").Compute("COUNT(Child(MovES_To_MovESItens).CodMovESItens)", String.Empty)

ERROR:
An unhandled exception of type 'System.Data.EvaluateException' occured in
system.windows.forms.dll
Additional information: Is not possible to evaluate. Expression
'Count(child([MovES_To_MovESItens]).[CodMovESItens])' is not aggregate.

I'm sure about the relations/tables/fields' names.
Please I need another sorte of eyes to look at it.

Thanks!
 
If i understand correctly, you want to compute the nb of "itens" for a given
MovEs record.

The easiest way is to add an expression column (ex: ItensCount) on the MovEs
table with the expression "COUNT(Child(MovES_To_MovESItens).CodMovESItens)".
This will give you the nb of itens for each MovEs record.
dtsMovEs.Columns.Add( "ItensCount" ).Expression = "

Then you can also do
dtsMovES.Tables("MovES").Compute("SUM(ItensCount)", String.Empty)
which will return you the total nb of Itens for the MovEs records.

You cannot use DataTable.Compute because it does not allow you to aggregate
over non local columns.
 
Back
Top