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

Query not being reexecuted on second, etc runs

edited April 2003 in General
I have a report that is not reexecuting the query. I am using Delphi 5
Pro and Report builder 6.03 Ent on a Win XP pro system. I have a program
that deletes a table and recreates it based on the data that is sent to
a FTP server. When the data arrives the program reads the file and
creates the table. After the data is processed the report which uses a
Tquery to execute a sql statement is printed. The first time the report
runs everything is correct. The second, third and etc times the report
is called it will only print the data from the first version of the
table and not the recreated table. I have tried calling the reset
procedure before and after printing the report but nothing changed. If I
exit the program and rerun it the first report is correct but the others
prints are not. I have also tried assigning the report to a second
report variable and setting it to nil after the report runs and I get
the same problem. Any idea of what is going on?
Tim

Comments

  • edited April 2003
    Tim,

    The Report.Reset procedure clears out the entire report cache so you won't
    receive cached data after it is called. First try taking ReportBuilder out
    of the equation and find out if your data is being properly updated. Hook a
    DBGrid to your datasource and see if the data changes the way you expect.
    If it does and you still experience the problem, please send an example to
    support@digital-metaphors.com and we'll take a look.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2003
    Thanks for the idea. I kept looking at the database itself and the data
    in it kept changing. I added a dbgrid and found that the data in the
    original data source is not being updated. This is a project I just took
    over. In doing this I discovered that the routine that is printing the
    report is trying to redefine the pipeline, the datasource, and tquery
    used by the report at runtime. This is being done so that the same
    procedure can print several reports. Sorry I did not note this early. I
    have not tested the other reports to see if I am having the same problem
    yet. I am thinking they are. The data in the new datasource is being
    updated. It appears though the report is still using the org pipeline,
    datasource and tquery when printing the report. Is this a good idea to
    do and what could be going wrong? I can understand what the org
    programmer was trying to do to save code but is not the way I would
    really like to do reports.

    Thanks
    Tim

    Here is the section of code that is trying to redefine the items:

    R := ReportByName(Report);

    // Run report
    Report_Query.Close;
    Report_Query.active := false;

    R.Printer.PrinterSetup.PrinterName:=MainForm.FaxPrnDrv;
    R.DeviceType := dtPrinter;

    Report_Source.DataSet := Report_Query;
    Report_Query.DataBaseName := 'WATCH';
    Report_Query.SQL.Clear;
    Report_Query.SQL.Add(sql_text);

    Report_PipeLine.DataSource := Report_Source;

    R.DataPipeLine := Report_PipeLine;

    application.processmessages;
    R.print;


  • edited April 2003
    Tim,

    There should be no need to create new data access components or
    datapipelines every time you want to print a new report. If you simply
    change the SQL in the your query and reprint the report, the changes will
    occur. Make sure you call Report.Reset before printing a report. Again make
    sure you test this using DBGrids to see if the data is being refreshed
    before you send it to a report. If you cannot get this to work, please send
    a simple example to support@digital-metaphors.com and we'll take a look.

    --
    Best Regards,

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