Page 1 of 1

Single Value

Posted: Mon 07 Jan 2008 21:23
by hanspeter
I want to question on a single value.

Code: Select all

IBCSql.Connection := IBConnection;
Transaction := TIBCTransaction.Create(nil);
IBCSql.Connection.AddTransaction(Transaction)


IBCSql.Text := 'select count(*) as count from Table';
with TParam(IBCSql.Params.Add) do begin
ParamType := ptOutPut;
DataType := ftInteger;
Name := 'count';
end;
IBCSql.Prepare; //To avoid auto unprepare after Execute
IBCSql.Execute;

Counter := IBCSql.ParambyName('count').asinteger;
Transaction.Free;
The Parameter "count" is blank.

How do I make it correctly?

Thanks
hanspeter

Posted: Tue 08 Jan 2008 11:50
by Plash
You should use TIBCQuery component to execute SELECT statement. Use Fields instead of Params to get a value, and do not add parameters.

Code: Select all

Counter := IBCQuery.FieldByName('count').AsInteger;