Re: TADOStoredProc



Paul,

If the underlying dataset (TADOStoredProc, TADOQuery, TADODataSet, etc) is
already open/active, calling Open doesn't do anything. If you need to
refresh, then you will need to Close first, then Open (or set Active :=
True). Kind of depends on your needs. In your storedproc example, if the
process is completed and you don't need the dataset active, then closing it
afterwards maybe a good option (clearing up memory space, etc).

In some areas of our apps, we save multiple round trips to the server for
static data by:

function TdmCommonLookUp.RefreshTermLookUp(const DefaultTermID :Integer)
:Boolean;
begin
with qTermLookUp do
begin { Start of with ADO query/dataset do }
FErrorMsg := ''; {clear ErrorMsg property}
DisableControls(); {prevents 'flicker' on any linked UI controls}
try
try { Start of try...except block }
if NOT(Active) then
begin
Open;
end;
First;
Result := Locate('TermID', DefaultTermID, []);
if NOT(Result) then
begin
FErrorMsg := 'Unable to locate TermID ' +
IntToStr(DefaultTermID);
end;
except
on e: Exception do
begin
Close; {just in case}
Result := False;
FErrorMsg := 'Unable to refresh term lookup due to
exception: ' + e.Message;
end;
end; { End of try...except block }
finally
EnableControls();
end;
end; { End of with ado query/dataset do }
end;

Good luck,
krf

"Paul Smith" <paul.smith@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:44e32f3c$2@xxxxxxxxxxxxxxxxxxxxxxxxx

Using TADOStoredProc I usually write the following code:
SP1.Parameters.ParamValues['@Param'] := 20;
with SP1 DO
BEGIN
OPEN;
BLAH BLAH
CLOSE;
END;

My question is do I need to close the result set at the end and
should it be in a finally clause? I see others actually close before they
open, is this needed? Will not closing cause performance issues?

Likewise for TADOQuery, do you have to set Active to false and close or is
there no need to bother?

Many thanks and your help is much appreciated.

Paul


.



Relevant Pages

  • Re: TADOStoredProc
    ... and events to TADOQuery, TADOStoredProc, TADOCommand and TADODataSet. ...
    (borland.public.delphi.database.ado)
  • Re: TADOStoredProc
    ... TadoStoredProc and TadoQuery are intended to match up with the properties ... TadoCommand do. ...
    (borland.public.delphi.database.ado)
  • Re: Truncated Blob Field in TADOQuery
    ... I used a TADOStoredProc instead and the problem went away. ... suspect that ti has to do with the manner in which TADOQuery handles ... and pumping it down into a MS SQL db locally. ... > of the parameter in the TADOQuery component before calling the ExecSQL ...
    (borland.public.delphi.database.ado)
  • Re: Repositioning a field corrupts DBGrid !!!
    ... because both TAdoQuery and TAdoStoredProc ... are decendants of TAdoCustomDataSet. ... The bug surfaces itself quite randomly. ...
    (borland.public.delphi.database.ado)