cavalry
asked on
Help - what's wrong with this query
I keep all sorts of EDB errors when running the following query and I'm at my wits end. Can anyone see or suggest what might be wrong. All I want to do is get the total of the Value field in the orders table. Thanks.
with Query1 do begin
Close;
with SQL do begin
Clear;
Add ('SELECT Sum (Value) FROM Orders');
end;
Open;
end;
with Query1 do begin
Close;
with SQL do begin
Clear;
Add ('SELECT Sum (Value) FROM Orders');
end;
Open;
end;
Try running the query in the Database Desktop. If you get no errors there, then try to be more specific with the error messages you get while running this from your code.
ASKER
I think Ive got it sorted now, BUT HOW do I show the result of the Sum calculation in a DBText component ??
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi cavalry,
is the dbtext.field connected to a datasource which is pointed to your query, the fieldname is the name of your aggregat-function (in this case SUM(VALUE)).
But the better way is zifs answer
meikl
is the dbtext.field connected to a datasource which is pointed to your query, the fieldname is the name of your aggregat-function (in this case SUM(VALUE)).
But the better way is zifs answer
meikl
Try to do the same thing without the use of With, the SQL look ok..
One other thing could be if you are tryingto close an query that is not active, I'm not quite sure if that is supported. Otherwise, use If Active Then Close