Re: TADOStoredProc
- From: "Kevin Frevert" <kevin@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 16 Aug 2006 10:03:05 -0500
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
.
- References:
- TADOStoredProc
- From: Paul Smith
- TADOStoredProc
- Prev by Date: TADOStoredProc
- Next by Date: Re: TADOQuery, OnFilterRecord and Locate
- Previous by thread: TADOStoredProc
- Next by thread: Re: TADOStoredProc
- Index(es):
Relevant Pages
|