Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

How to use OrderByFields in TdaSQLBuilder ???

edited December 2004 in General
I am having problems trying to sort the columns of a report using
TdaSQLBuilder.
I have a simple Delphi program with 4 radio buttons to select the sort
order.

This is the code in the OnInitializeParameters event-handler:

//--------------------------------------------------------------------------
----------//

procedure TForm1.ppReport1InitializeParameters(Sender: TObject; var aCancel:
Boolean);
var
ISQLBuilder: TdaSQLBuilder;

begin

ISQLBuilder := TdaSQLBuilder.Create(ppReport1);
ISQLBuilder.Clear;

ISQLBuilder.SelectTables.Add('Calendar');

ISQLBuilder.SelectFields.Add('Calendar','Co');
ISQLBuilder.SelectFields.Add('Calendar','Period');
ISQLBuilder.SelectFields.Add('Calendar','DtStart');
ISQLBuilder.SelectFields.Add('Calendar','DtEnd');
ISQLBuilder.SelectFields.Add('Calendar','WkDays');

ISQLBuilder.OrderByFields.Clear;

case RadioGroup1.ItemIndex of
0: ISQLBuilder.OrderByFields.Add('Calendar','Co');
1: ISQLBuilder.OrderByFields.Add('Calendar','Period');
2: ISQLBuilder.OrderByFields.Add('Calendar','DtStart');
3: ISQLBuilder.OrderByFields.Add('Calendar','DtEnd');
end;

ISQLBuilder.Free;

end;

//--------------------------------------------------------------------------
----------//

All the data definitions are inside the report -using DADE-, in the Delphi
form I just
have the ADOConnection and a ppReport, do I need a ppPipeline in the form
???

There is also a Print button which call "ppReport1.Print".

The first time you execute the program, the report is in the correct order
but, after
that, you can modify it. I've been ckecking and modifying the Items array
with no success.
Where is the sorted information stored ???

I have not tried with the AutoSearch methos yet, hopefully that feature is
working OK.
Anyway it would be great to have a sample application showing us how to use
these new
features and how to do the same using RAP.

Best regards,
Jorge.

Comments

  • edited December 2004

    In my testing here, I had to add to the following statement to the top of
    your method.

    ppReport1.DataPipeline.Close;


    For the next release we'll enhance the TdaSQLBuilder and TdaSQL classes so
    that the call is not necessary.


    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited December 2004
    Hello Nard,

    Thanks for your answer. I tried your suggestion and now the sort order in
    the report is working fine.
    Yesterday I discovered that calling the method ppReport1.Reset also resolve
    the problem.

    Is there any way to call the TdaSQLBuilder methods from RAP ? Or at least
    pass the info as parameters ?

    Regards,
    Jorge

  • edited December 2004

    Include daSQLBuilder in the uses clause of your application - this will
    register the TdaSQLBuilder and its RAP RTTI classes. RAP does not support
    overloading, so some of the overloaded methods may not be callable from RAP
    or may have different names. You can check the daSQLBuilder.pas unit if you
    encounter questions. The classes suffixed with 'RTTI' define the methods
    that are available.

    RAP also supports Report.Parameters[].



    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.