Solved

how to add all fields to query programicaly?

Posted on 2004-10-26
298 Views
Last Modified: 2012-05-05
i'm using this query:

AdoQuery1.SQL.Clear;
AdoQuery1.SQL.Add('select krupje, laikas, skirtumas, viso from chipsai where laikas > '+QuotedStr(DatetoStr(DateTimePicker1.Date - 1))+' order by laikas');
AdoQuery1.Open;

and i want to clear old field
and to add these fields to query programicaly like in fields editor
0
Question by:selas
    4 Comments
     
    LVL 27

    Accepted Solution

    by:
    ??
    usual its done automatically after the open-method
    you can force it with Dataset.FieldDef.Update;

    just from head

    meikl ;-)
    0
     
    LVL 12

    Expert Comment

    by:esoftbg
    AdoQuery1.SQL.Active := False;
    AdoQuery1.SQL.Text := 'select krupje, laikas, skirtumas, viso from chipsai where laikas > '+QuotedStr(DatetoStr(DateTimePicker1.Date - 1))+' order by laikas';
    AdoQuery1.SQL.Active := True;

    //....

    Using:
    AdoQuery1.SQL.Text := ....;
    you clear whole old content and replace with new one
    0
     
    LVL 12

    Expert Comment

    by:esoftbg
    If you have a problem with assigning the condition in the clause WHERE:
     .... WHERE LAIKAS > ' + QuotedStr(DatetoStr(DateTimePicker1.Date - 1)) ....

    you may use a parameter:

    AdoQuery1.SQL.Active := False;
    AdoQuery1.SQL.Text := 'select krupje, laikas, skirtumas, viso from chipsai where LAIKAS > :PRM_LAIKAS order by laikas';
    AdoQuery1.Parameters.ParamByName('PRM_LAIKAS').Value := TDateTime(DateTimePicker1.Date - 1);
    AdoQuery1.SQL.Active := True;
    0
     
    LVL 12

    Expert Comment

    by:esoftbg
    let
    > AdoQuery1.SQL.Active := .... // True or False;
    to be
       AdoQuery1.Active := .... // True or False;

    sorry ....
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles al…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    934 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now