Re: ADO Performance / Optimize?
From: Andrew (abaylis_nos_at_spamcop.net)
Date: 07/14/04
- Next message: Brian Bushay TeamB: "Re: Diamond Access"
- Previous message: jason: "Re: Strange problem"
- In reply to: Todd Jaspers: "ADO Performance / Optimize?"
- Next in thread: Brian Bushay TeamB: "Re: ADO Performance / Optimize?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 14 Jul 2004 10:59:51 +1000
"Todd Jaspers" <tjaspers@bellsouth.net> wrote in message
news:40f3de49@newsgroups.borland.com...
> Hey guys,
<snip>
> Below is a typical example of one of my queries:
>
> Function TCP_Main_Frm.CheckAcc(FormatSpec: String) : String;
> Var
> SQLStatement : String;
> Begin
> SQLStatement :=
> ('SELECT T1.specimen_id, T1.specnum_formatted '
> + 'FROM c_specimen T1 '
> + 'WHERE T1.specnum_formatted = "' + FormatSpec + '"');
>
> CPXML_DATA.DM.CP_Query.SQL.Clear;
> CPXML_DATA.DM.CP_Query.SQL.Text := SQLStatement;
> CPXML_DATA.DM.CP_Query.Active := True;
> Result := CPXML_DATA.DM.CP_Query.FieldByName('specimen_id').AsString;
> CPXML_DATA.DM.CP_Query.Active := False;
> CPXML_DATA.DM.CP_Query.SQL.Clear;
> End;
>
>
>
> I'm posting this because I hope you'll take notice of the ACTIVE = TRUE
and
> then ACTIVE = FALSE commands that I use. Is there a better way? Do I
really
> need to active / inactivate the query component each time? Or can I leave
> the query active the entire time, and just execute it?
>
>
>
> Thanks!
>
> Todd
>
Todd,
A quicker approach if you are using the same base query would be to set it
up with a parameter, then requery when the parameter is changed.
eg: SQLStatement := 'SELECT T1.specimen_id, T1.specnum_formatted '
+ 'FROM c_specimen T1 '
+ 'WHERE T1.specnum_formatted = :Param1);'
For the first occasion, set the parameter (ParamByName('Param1').AsString
....) and then Open the query. For each subsequent time, just set the
parameter and call Requery (ie. no need to close and reopen).
HTH
Andrew
- Next message: Brian Bushay TeamB: "Re: Diamond Access"
- Previous message: jason: "Re: Strange problem"
- In reply to: Todd Jaspers: "ADO Performance / Optimize?"
- Next in thread: Brian Bushay TeamB: "Re: ADO Performance / Optimize?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|