Solved

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

Posted on 2004-04-19
6
1,332 Views
Last Modified: 2008-02-26
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
Comment
Question by:Randy Rich
  • 3
  • 3
6 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 10861585
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
 

Author Comment

by:Randy Rich
ID: 10861739
>>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
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 10865685
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:Randy Rich
ID: 10870833
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
 

Author Comment

by:Randy Rich
ID: 10873277
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 10874286
Glad I could help

mlmcc
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now