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

Top N Report - Issue since upgrading from 6.03 to 10.09

edited November 2008 in General
Hi Everyone

I've recently upgraded a project from RB 6.03 Ent to RB 10.09 Ent in delphi
6 that contained a "Top N" report, with the back end sitting on MSSQL
2000/2005

Obviously with this database backend, I have to use the SELECT TOP X
methodology. Under RB 6.03 the report worked no hassles what so ever. But
under rb 10.09, I get an access violation before the report even generates.

How I accomplish the Top N functionality is as follows. The reporting system
is built on top of the end user reporting form.

1) in Report.GlobalOnCreate() I call a RAP function that does the following

var
lReport : TppReport;
DataView : TdaQueryDataView;
SelectString : String;
begin
GetParamValue(0, lReport);

DataView := TdaQueryDataView(lReport.DataPipeline.DataView);

// Need to create the SQL here before changing incase there
// are parameters supplied to the report
DataView.SQL.CreateSQL();
DataView.SQL.EditSQLAsText := True;
SelectString := DataView.SQL.SQLText[0];
SelectString := StringReplace(SelectString,
'SELECT',
'SELECT TOP ' + IntToStr(TopNRecords),
[rfIgnoreCase]);
DataView.SQL.SQLText[0] := SelectString;

This function works in both 6.03, and 10.09, but the access violation
occurs if I run that RAP Function in 10.09.

The Access Violation occurs in daQueryDataView.pas, in method
TdaQueryDataView.ReportGetAutoSearchValuesEvent. Within the function, the
following code causes the access violation (Lines 1567 - 1573)

1567: lField := lMainReport.AutoSearchFields[liIndex];
1568:
1569: if (lField.DataView = Self) then
1570: begin
1571: lCriteria := TdaCriteria(lField.Criteria);
1572:
1573: lCriteria.Field.ShowAllValues := lField.ShowAllValues;
<---- Access Violation

For whatever reason - lField.Criteria is Nil if I modify the SQL as
described above. If I leave the Dataview alone, then the code does not cause
any access violation. So whatever changing the SQL at run time is doing is
causing an issue.

Am I missing something with 10.09 that would cause this access violation to
occur?

Any feedback would be greately appreciated

Regards
Scott
S&M Software Solutions

Comments

  • edited November 2008
    > This function works in both 6.03, and 10.09, but the access violation

    Just a clarification - The RAP function executes correctly irrespective of
    the version. The access violation occurrs when the Engine tries to get the
    AutoSearchDialog (TppReport.ShowAutoSearchDialogBeforePrinting)

    Thanks
    Scott
  • edited November 2008
    Hi Scott,

    For ReportBuilder 10, we needed to move the order of when the GlobalOnCreate
    event fired. Try moving your RAP code to one of the new earlier events such
    as the OnInitializeParameters or OnBeforeOpenDataPipelines.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2008
    Hi Nico

    Thanks for the response.

    I moved the SetTopN code into the OnInitializeParameters Callback and the
    same access violation occurred.
    I tried the same SetTopN code in the OnBeforeOpenDataPipelines and that
    seemed to work like a treat.
    So the issue has been resolved.

    Is there a do's/don't/gotchas anywhere in the documentation or on the Wiki
    to cover these sorta upgrade issues? I tend to only ask for help as a last
    resort :)

    But to Nico, thank you again for the help and the solution to the issue,

    Thanks
    Scott
    S&M Software Solutions

  • edited November 2008
    Hi Scott,

    This was the big change with the timing of RAP events for RB 10. For the
    most part, our goal is to keep all new versions of ReportBuilder backward
    compatible however in some cases we are forced to correct a major flaw.
    There shouldn't be any more big "gotchas" that you need to be aware of for
    RB 10 however if you do run across any issues, please post and we'll help
    you solve them.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2008
    Thanks again Nico. I appreciate the time and response. :)

    If i find anything more I will post for sure.

    Thanks again for your support.

    Scott
This discussion has been closed.