| View previous topic :: View next topic |
| Author |
Message |
Kostas Liatifis Guest
|
Posted: Thu Mar 10, 2005 7:58 pm Post subject: second problem sum |
|
|
Dear sir
I have this statement
Function TMasterDataDC.ExecIBSQL ( aTable:TIBTable; aSQL:TIBSQL ): Boolean ;
begin
try
with MasterDataDC do
begin
aSQL.Prepare;
aSQL.ExecQuery;
TransDC.Commit;
Result := True;
end;
except
MasterDataDC.TransDC.Rollback;
Result := False;
end;
aTable.Open;
if Assigned ( aTable ) then aTable.Refresh;
aTable.Close;
end ;
after this i have this statement
IBQuery.SQL.Add('Select Sum(SumField) AS Sum_Field from IBTable where
(Field=:Field)');
IBQuery.ParamByName('Field').AsInteger:=AInteger;
IBQuery.Open;
I:=IBQuery.FieldByName('Sum_Field').asInteger;
after this the value of sum is 0
but if i closed the application and i opened again then i have the result
why?
where is the problem?
Thank you
|
|
| Back to top |
|
 |
Barak zabari Guest
|
Posted: Sun Mar 13, 2005 4:51 pm Post subject: Re: second problem sum |
|
|
I have some problem understanding your code.
I see that you pass the Table and Query as parmeters then you use a
Component called TransDC ( i assume this ia TIBTransaction).
Why not use aSQL.transaction.commit?
that way you know you commit the right object.
I am not sure what value AInteger got (i assume it's something you insert
with aSQL) and since you get a Zero as a return value i think your problem
is with the commit;
"Kostas Liatifis" <texilia (AT) otenet (DOT) gr> wrote
| Quote: | Dear sir
I have this statement
Function TMasterDataDC.ExecIBSQL ( aTable:TIBTable; aSQL:TIBSQL ): Boolean
;
begin
try
with MasterDataDC do
begin
aSQL.Prepare;
aSQL.ExecQuery;
TransDC.Commit;
Result := True;
end;
except
MasterDataDC.TransDC.Rollback;
Result := False;
end;
aTable.Open;
if Assigned ( aTable ) then aTable.Refresh;
aTable.Close;
end ;
after this i have this statement
IBQuery.SQL.Add('Select Sum(SumField) AS Sum_Field from IBTable where
(Field=:Field)');
IBQuery.ParamByName('Field').AsInteger:=AInteger;
IBQuery.Open;
I:=IBQuery.FieldByName('Sum_Field').asInteger;
after this the value of sum is 0
but if i closed the application and i opened again then i have the result
why?
where is the problem?
Thank you
|
|
|
| Back to top |
|
 |
|