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

TppDbText doesn?t show values correctly

edited January 2007 in Datapipelines
I have a report with any objects TppDbText and others objects TppLabel.
My object TppReport is created in runtime. After, my template is loaded from
database and I set the AutoSearchFields (Example: Customer 1). Then call
Print.
In the first print, the objects TppDbText of my template shows the values
correctly (refers the data of pipeline and AutoSearchFields sets: Customer
1).
After, without to destroy my object TppReport, I set the AutoSearchFields
with new values (Customer 2) and call Print.
The objects TppDbText shows the values the previous report (Customer 1), but
TppLabels with Events GetText (Text:= Pipeline[Data]) shows the values the
report correctly (Customer 2).
What it?s occurred? Thank?s.

Giovana Nunes
Futura Tecnologia
giovana@futuranet.com.br

Comments

  • edited January 2007
    Hi Giovana,

    Which version of ReportBuilder/Delphi are you using? When exactly and how
    are you changing the autosearch values? It seems that perhaps you are
    changing these values too late for them to take effect before the report
    reprints.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2007
    Hi,

    I use Report Builder 7.04 and Delphi 7, I don?t want that load the template
    always. I try two cases and one case isn?t OK.

    My class:
    Type
    TTeste = class(TObject)
    private
    FLayout: TppReport;
    public
    property Layout: TppReport read FLayout write FLayout;
    procedure Imprime;
    constructor Create; overload;
    end;

    implementation

    { TTeste }

    constructor TTeste.Create;
    begin
    Layout:= TppReport.Create(application);
    with Layout do begin
    PrinterSetup.BinName := 'Default';
    PrinterSetup.DocumentName := 'Report';
    PrinterSetup.PaperName := 'A4';
    PrinterSetup.PrinterName := 'Default';
    OutlineSettings.CreateNode := True;
    OutlineSettings.CreatePageNodes := True;
    OutlineSettings.Enabled := True;
    OutlineSettings.Visible := True;
    TextSearchSettings.DefaultString := '';
    TextSearchSettings.Enabled := True;
    Version := '7.04';
    end;
    end;

    Now, two cases:

    * Case 1:
    procedure TTeste.Imprime;
    var xPipe: TppDBPipeline;
    xDTS: TDataSource;
    xQuery: ToeQuery;
    begin
    xPipe:= TppDBPipeline.Create(application);
    xDTS:= TDataSource.Create(application);
    xQuery:= ToeQuery.Create(application);
    try
    xQuery.HDBC:= FRMPRINCIPAL.CONEXAOODBC;
    xQuery.SQL.Text:= 'select seqlayout, layout, arquivo from exportacao
    where seqlayout = 82';
    xDTS.DataSet:= xQuery;
    xPipe.DataSource:= xDTS;
    xQuery.Open;
    with Layout do begin
    DataPipeLine:= xPipe;
    template.DatabaseSettings.DataPipeLine:= xPipe;
    template.DatabaseSettings.NameField:= 'Arquivo';
    template.DatabaseSettings.TemplateField:= 'Layout';
    Template.DataBaseSettings.Name:=
    xQuery.FieldbyName('Arquivo').AsString;
    Template.LoadFromDatabase;
    ShowAutoSearchDialog:= false;
    AutoSearchFields[0].SearchExpression := '1';
    Print;
    AutoSearchFields[0].SearchExpression := '2';
    Print;
    end;
    finally
    xQuery.Close;
    xPipe.Free;
    xDTS.Free;
    xQuery.Free;
    end;
    end;

    In my form, I call:
    xTeste:= TTeste.Create;
    xTeste.Imprime; ----> Ok, in the first print the data is customer 1 and
    in the second print the data is customer 2.
    xTeste.Free;

    Then, I quit the form and call again:
    xTeste:= TTeste.Create;
    xTeste.Imprime; ----> Ok, in the first print the data is customer 1 and
    in the second print the data is customer 2.
    xTeste.Free;

    * Case 2:
    procedure TTeste.Imprime;
    var xPipe: TppDBPipeline;
    xDTS: TDataSource;
    xQuery: ToeQuery;
    begin
    xPipe:= TppDBPipeline.Create(application);
    xDTS:= TDataSource.Create(application);
    xQuery:= ToeQuery.Create(application);
    try
    xQuery.HDBC:= FRMPRINCIPAL.CONEXAOODBC;
    xQuery.SQL.Text:= 'select seqlayout, layout, arquivo from exportacao
    where seqlayout = 82';
    xDTS.DataSet:= xQuery;
    xPipe.DataSource:= xDTS;
    xQuery.Open;
    with Layout do begin
    DataPipeLine:= xPipe;
    template.DatabaseSettings.DataPipeLine:= xPipe;
    template.DatabaseSettings.NameField:= 'Arquivo';
    template.DatabaseSettings.TemplateField:= 'Layout';
    Template.DataBaseSettings.Name:=
    xQuery.FieldbyName('Arquivo').AsString;
    Template.LoadFromDatabase;
    ShowAutoSearchDialog:= false;
    AutoSearchFields[0].SearchExpression := '1';
    Print;
    end;
    xPipe:= TppDBPipeline.Create(application);
    xDTS:= TDataSource.Create(application);
    xQuery:= ToeQuery.Create(application);
    xQuery.HDBC:= FRMPRINCIPAL.CONEXAOODBC;
    xQuery.SQL.Text:= 'select seqlayout, layout, arquivo from exportacao
    where seqlayout = 82';
    xDTS.DataSet:= xQuery;
    xPipe.DataSource:= xDTS;
    xQuery.Open;
    with Layout do begin
    DataPipeLine:= xPipe;
    template.DatabaseSettings.DataPipeLine:= xPipe;
    template.DatabaseSettings.NameField:= 'Arquivo';
    template.DatabaseSettings.TemplateField:= 'Layout';
    Template.DataBaseSettings.Name:=
    xQuery.FieldbyName('Arquivo').AsString;
    Template.LoadFromDatabase;
    ShowAutoSearchDialog:= false;
    AutoSearchFields[0].SearchExpression := '2';
    Print;
    end;

    finally
    xQuery.Close;
    xPipe.Free;
    xDTS.Free;
    xQuery.Free;
    end;
    end;

    In my form, I call:
    xTeste:= TTeste.Create;
    xTeste.Imprime; ----> Ok, in the first print the data is customer 1 and
    in the second print the data is customer 2.
    xTeste.Free;

    Then, I quit the form and call again:
    xTeste:= TTeste.Create;
    xTeste.Imprime; ----> Ok, in the first print the data is customer 2 and
    in the second print the data is customer 2.
    xTeste.Free;
    Now, while I don?t quit the system, always print the data is customer 2. If
    I edit the layout, the new layout show ok. If I have labels that getText use
    data, the caption show ok, but the objects dbText shows the old data.

    I need to have one object singleton that load the template in x minutes!

    Thank?s

    Giovana Nunes
    -
  • edited January 2007
    Giovana,

    If you trace your code in case 2, does the code that assigns the AutoSearch
    value ever fire correctly? After this property is set, does the AutoSearch
    field contain this value or is it being printed or changed at some point.
    Try stepping through this code to find out where (on the second run) the
    autosearch value is being reset to "2".

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2007
    I tryed to trace my report, in event Report.BeforePrint shows
    report.AutoSearchFields[0].value always correct, but the values is objects
    TppDb... incorrect. The labels is correct too.
    I think that any property of TppReport needs to set, because when I use a
    object TppReport in the form show all values correct.

    Example:
    procedure TTeste.Imprime(xReport: TppReport);
    var xPipe: TppDBPipeline;
    xDTS: TDataSource;
    xQuery: ToeQuery;
    begin
    Layout:= xReport;


    xTeste:= TTeste.Create;
    xTeste.Imprime(ppReport1);
    xTeste.Free;

    Thank?s

    Giovana Nunes.

  • edited January 2007
    Hi Giovana,

    If possible, please send a minimal example I can run on my machine that
    demonstrates this behavior in .zip format to support@digital-metaphors.com
    and I'll take a look at it for you.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.