Re: ADO Performance / Optimize?

From: Andrew (abaylis_nos_at_spamcop.net)
Date: 07/14/04


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



Relevant Pages

  • Re: Trouble combining arrays in a table
    ... I'm querying Salesforce.com via their AJAX toolkit and outputting query ... var Account, primaryContact, lastRow; ... var table, thead, row, cell, cellText; ...
    (comp.lang.javascript)
  • Re: Selecting a variable value with Linq
    ... var xmap = from dmap in map.Descendants ... (this is from the xmap query). ... I can tell you that variables are "captured" in a lambda used as ... Each time you enumerate the "query" reference, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Current Row or similar for query-based combo box
    ... The requery solution is working very well. ... You can use the form's current event to force the combobox to be requeried. ... form.in my combobox query I am able to get the intended result. ... rows that need other values to display will suddenly display blank. ...
    (microsoft.public.access.queries)
  • Requery error message query wont run
    ... qdf.Execute dbFailOnError ... When I am in form view and select a State the requery code automatically ... In my other form I need to update Room assignments to remove the room from ... run an update query…” I click on Yes and the query runs and indicates 1 ...
    (microsoft.public.access.formscoding)
  • Re: How to requery grid based on query
    ... you will get the REQUERY() orportunity if you use a view instead of a query. ... CREATE SQL VIEW Command ... Form runs, grid> displays data. ... a grid does not have a requery> method. ...
    (microsoft.public.fox.programmer.exchange)