Solved

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

Posted on 2004-04-19
6
1,336 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

24 Experts available now in Live!

Get 1:1 Help Now