[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1378
  • Last Modified:

While running Crystal Reports from Delphi 5, ntdll.dll error when exiting application

I’m using the Crystal Reports VCL Version 7 component (7vcl551) for Delphi 5.  I have a report that utilizes 6 sub reports.  The report runs great, but when I exit the application I get the error Access Violation in module NTDLL.dll.

If I omit the references to the parameters (see code below), the reports runs fine and the application exits without an error, except of course I can’t change the parameters.

I’ve tried everything I can think of.  My component name is crpe1.  Here is my source code to call the report:

                with crpe1 do
                  try
                    my_crop_year := str_to_int(cmb_crop_year.text,jok);
                    ReportName := 's:\tws\reports\connell\acres_summary.rpt';

                    {***** IF I OMIT THE CODE STARTING HERE ******}

                    Paramfields.retrieve;


                    // parameters for main report
                    Paramfields.name := 'crop_year';
                    Paramfields.asNumber := my_crop_year;
                    Paramfields.name := 'variety_id';
                    Paramfields.Value := cmb_variety_id.text;
                    Paramfields.name := 'lbl_title';
                    Paramfields.Value := 'RPBH 100 - Acres Summary Report '+cmb_crop_year.text+' Crop - as of '+datetostr(cmb_report_date.date);
                    Paramfields.name := 'lbl_variety';
                    Paramfields.Value := 'Variety - '+cmb_variety_id.text;


                    // ************ subreport1 **********************************************************
                    Paramfields.name := 'acres_signed_in_year';
                    Paramfields.Value := 'Acres Signed in '+cmb_crop_year.text;
                    Paramfields.name := 'a_1';
                    Paramfields.asNumber := my_crop_year;
                    Paramfields.name := 'a_2';
                    Paramfields.asNumber := my_crop_year-1;
                    Paramfields.name := 'a_3';
                    Paramfields.asNumber := my_crop_year-2;
                    Paramfields.name := 'a_4';
                    Paramfields.asNumber := my_crop_year-3;
                    Paramfields.name := 'c_1';
                    Paramfields.asNumber := my_crop_year;
                    Paramfields.name := 'v_1';
                    Paramfields.Value := cmb_variety_id.text;


                    //sub report 2 *****************************************************************************
                    Paramfields.name := 'c_2';
                    Paramfields.asNumber := my_crop_year;
                    Paramfields.name := 'v_2';
                    Paramfields.Value := cmb_variety_id.text;

                    // subreport 3 *****************************************************************************

                    Paramfields.name := 'b_3';
                    Paramfields.asNumber := my_crop_year-4;
                    Paramfields.name := 'e_3';
                    Paramfields.asNumber := my_crop_year;
                    Paramfields.name := 'v_3';
                    Paramfields.Value := cmb_variety_id.text;
                    Paramfields.name := 't_3';
                    Paramfields.Value := cmb_crop_year.text+' Estimated CWTs';
                    Paramfields.name := 'r_3';
                    Paramfields.Value := 'Acres Signed Up as of '+datetostr(cmb_report_date.date);
                    with dmposting.q_sql do
                      begin
                        active := false;
                        sql.clear;
                        sql.add('SELECT CWTS/CURRENT_ACRES RATE, CWTS FROM ACRES_SIGNED WHERE VARIETY_ID = '''+cmb_variety_id.text+''' AND CROP_YEAR = '+cmb_crop_year.text);
                        active := true;
                        Paramfields.name := 'rate_3';
                        Paramfields.Value := 'Rate@'+fieldbyname('RATE').asstring+' Acres/CWT = '+format('%12.2n',[fieldbyname('CWTS').asfloat])+' CWTs';
                        active := false;
                      end;


                    //sub report 4 ********************************************************************************
                    Paramfields.name := 'c_4';
                    Paramfields.asNumber := my_crop_year;
                    Paramfields.name := 'v_4';
                    Paramfields.Value := cmb_variety_id.text;
                    Paramfields.name := 'prior_4';
                    Paramfields.asNumber := my_crop_year-1;

                    //sub report 5 *********************************************************************************
                    Paramfields.name := 'c_5';
                    Paramfields.asNumber := my_crop_year;
                    Paramfields.name := 'v_5';
                    Paramfields.Value := cmb_variety_id.text;
                    Paramfields.name := 't_5';
                    Paramfields.Value := 'Forecast '+cmb_crop_year.text+' Pool';

                    //sub report 6 *********************************************************************************
                    Paramfields.name := 'c_6';
                    Paramfields.asNumber := my_crop_year;
                    Paramfields.name := 'v_6';
                    Paramfields.Value := cmb_variety_id.text;

                    {**** DOWN TO HERE IT RUNS FINE}

                    ConnectMethod := useConnect;
                    Connect.Retrieve;
                    Connect.ServerName := 'ORACLE1';
                    Connect.UserID := 'SYSDBA';
                    Connect.Password := 'MASTERKEY';
                    Connect.DatabaseName := 'ORACLE1';
                    Output := toWindow;
                    Execute;
                  finally
                    CloseJob;
                  end;


Any help would be greatly appreciated.

Thanks
0
Randy Rich
Asked:
Randy Rich
  • 3
  • 3
1 Solution
 
mlmccCommented:
I am not familiar with the Delphi VCL.

Does it work correctly if you pass parameters only to the main report?

Where are you adding the parameters to the report?

From VB  I believe I have to add the parameters separately to each subreport not all at once.

mlmcc
0
 
Randy RichPresidentAuthor Commented:
>>Does it work correctly if you pass parameters only to the main report?

I tried that.  Simply calling the method parameters.retrieve causes the app to become unstable.

>>Where are you adding the parameters to the report?

The parameters were added to the report when the .rpt file was created.  Each sub-report has it's own set of parameters.  I reference them from the body of my delphi source code like this:

                   // here i name the report
                   ReportName := 's:\tws\reports\connell\acres_summary.rpt';
                   // after that I retrieve the variables from the report
                    Paramfields.retrieve;

                    //sub report 2 *****************************************************************************
 
                    // this line seeks out the parameter named 'c_2' in sub report 2
                    Paramfields.name := 'c_2';
                   // this lines assigns a value to it
                    Paramfields.asNumber := my_crop_year;

                 
                   // then i run the report
                    ConnectMethod := useConnect;
                    Connect.Retrieve;
                    Connect.ServerName := 'ORACLE1';
                    Connect.UserID := 'SYSDBA';
                    Connect.Password := 'MASTERKEY';
                    Connect.DatabaseName := 'ORACLE1';
                    Output := toWindow;
                    Execute;
                  finally
                    CloseJob;
                  end;




>>From VB  I believe I have to add the parameters separately to each subreport not all at once.

I thought that might be the issue as well, but none of the documentation backed that up and the variables were passed just fine by simply referencing the parameter name.

Thanks for your response
0
Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

 
Randy RichPresidentAuthor Commented:
That was very useful but didn't help my situation because I'm still having problems passing parameters. If I pass a value to the parameter I get an error message.  See Below

procedure TForm1.FormActivate(Sender: TObject);
begin
  report := Application1.OpenReport('s:\tws\reports\connell\acres_summary.rpt',crOpenReportByTempCopy);

  // Using AddCurrentValue if I use the default value embedded in the report for this parameter
  // I get an error message stating that the value/range I'm adding already existed.
  // If I use a different value (e.g. 2004), it says the "Server has not yet been Opened"
  Report.ParameterFields.item[1].AddCurrentValue(2004);

  crViewer1.ReportSource := Report;
  crViewer1.ViewReport;
end;
0
 
Randy RichPresidentAuthor Commented:
Ok, I finally figured this out.  The issue here is that I'm using DOA components by Allaround Automation.    The TOracleSession has a property named UseOCI7.  Setting this property to True will cause the session to use the old, but more stable SQL*Net 2.3 functions in Net8.  This can be helpful in case of Net8 problems, but can only be used if your application is not using any Net8 specific objects (TLOBLocator, TOracleObject and TOracleReference).  Setting this property to TRUE eliminated the problem.  Now the application exits perfectly.  
0
 
mlmccCommented:
Glad I could help

mlmcc
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now