Board index » delphi » Crystal VCL causes system crash!!

Crystal VCL causes system crash!!

Hello,

I am getting an abrupt system crash and reboot when I try to access a
Crystal Report (say Report A) through the Seagate Crystal VCL.

"Report A" contains parameter fields which are passed values through the
vcl.  Other reports with parameters work fine, and this report worked fine
a few days ago.

I am running CrystalReports 7.0.15,  Delphi 4 update3  with Crystal VCL
7.52.

The code I wrote for "Report A"
     Form1.Crpe1.ReportName:= 'c:\Reports\Report A.rpt';
     Form1.Crpe1.ParamFields.Retrieve;
     Form1.Crpe1.ParamFields[0].RetrieveValues;
     Form1.Crpe1.ParamFields[1].RetrieveValues;
     Form1.Crpe1.ParamFields[0].AsDateTime:= startDate;
     Form1.Crpe1.ParamFields[1].AsDateTime:= endDate;
     Form1.Crpe1.Printer.Retrieve;
     Form1.Crpe1.Printer.PreserveRptSettings :=
[prOrientation,prPaperSize,prPaperSource];
     Form1.Crpe1.ConnectMethod := useConnect;
     Form1.Crpe1.Connect.Password := '_password_';
     Form1.Crpe1.Output := toWindow;
     Form1.Crpe1.Execute;

Any ideas of what is causing this complete system crash?

Then I modified the application (as below) so that this report uses its own
TCRpe component and the system did not crash but it gave me the following
error:

Project crystal2Delphi.exe raised exception class EAccessViolation with
message 'Access violation at address 6A90759D in module 'C2PCL40U.DLL'. Read
of Address 6A96CFE0'. Process stopped. Use Step or Run to continue.

    Crpe1.ReportName:= 'c:\Reports\Report A.rpt';
    Crpe1.ParamFields.Retrieve;
    Crpe1.ParamFields[0].RetrieveValues;
    Crpe1.ParamFields[1].RetrieveValues;
    Crpe1.ParamFields[0].AsDateTime:= startDate;
    Crpe1.ParamFields[1].AsDateTime:= endDate;
    Crpe1.Printer.Retrieve;
    Crpe1.Printer.PreserveRptSettings :=
[prOrientation,prPaperSize,prPaperSource];
    Crpe1.ConnectMethod := useConnect;
    Crpe1.Connect.Password := '_password_';
    Crpe1.Output := toWindow;
    Crpe1.Execute;

Thanks in advance for any clues, debugging ideas, anything!!

Pat Bundon

 

Re:Crystal VCL causes system crash!!


I suggest that you step through the code to determine which line is
causing the crash.  If you do not want to step through the CR VCL code,
you could move your breakpoint forward one line at a time.  When you
find this out, perhaps we could help (and perhaps not!).

John Pierce

Re:Crystal VCL causes system crash!!


Quote
Pat Bundon wrote:
> Hello,

> I am getting an abrupt system crash and reboot when I try to access a
> Crystal Report (say Report A) through the Seagate Crystal VCL.

> "Report A" contains parameter fields which are passed values through the
> vcl.  Other reports with parameters work fine, and this report worked fine
> a few days ago.

> I am running CrystalReports 7.0.15,  Delphi 4 update3  with Crystal VCL
> 7.52.

> The code I wrote for "Report A"

>      Form1.Crpe1.ReportName:= 'c:\Reports\Report A.rpt';
>      Form1.Crpe1.ParamFields.Retrieve;
>      Form1.Crpe1.ParamFields[0].RetrieveValues;
>      Form1.Crpe1.ParamFields[1].RetrieveValues;
>      Form1.Crpe1.ParamFields[0].AsDateTime:= startDate;
>      Form1.Crpe1.ParamFields[1].AsDateTime:= endDate;
>      Form1.Crpe1.Printer.Retrieve;
>      Form1.Crpe1.Printer.PreserveRptSettings :=
> [prOrientation,prPaperSize,prPaperSource];
>      Form1.Crpe1.ConnectMethod := useConnect;
>      Form1.Crpe1.Connect.Password := '_password_';
>      Form1.Crpe1.Output := toWindow;
>      Form1.Crpe1.Execute;

Upon further thought, I have had problems with CR where paths contain spaces.
They seem particularly severe with W98.

ParamFields.Retrieve clears the values, so, at best,
ParamFields[0].RetrieveValues does nothing, and, at worst might cause your
crash.

Printer.Retrieve should not be necessary, since you don't change any settings,
but I
don't think it does any harm.

After .ConnectMethod I think you have to use .ConnectRetrieve, though this is
not tested since I use the LogON.

John Pierce

Re:Crystal VCL causes system crash!!


Thanks John,

I thought about it a little more clearly this morning and was able to find
an example which also reminded me to use Connect.Retrieve. Using that before
Crpe1.Connect.Password is set seems to solve the problem.
I also removed the paramfield[i].retrieve lines.   Seems to work well now.

Thanks for all the pointers.  You've been a terrific help!

Pat Bundon
for reference, when was crashing the system it always happened on execution
of Crpe1.Execute;

Quote
"John Pierce" <jpie...@healthplanning.com> wrote in message

news:395CE02B.A6BA5B2@healthplanning.com...
Quote

> Pat Bundon wrote:

> > Hello,

> > I am getting an abrupt system crash and reboot when I try to access a
> > Crystal Report (say Report A) through the Seagate Crystal VCL.

> > "Report A" contains parameter fields which are passed values through the
> > vcl.  Other reports with parameters work fine, and this report worked
fine
> > a few days ago.

> > I am running CrystalReports 7.0.15,  Delphi 4 update3  with Crystal VCL
> > 7.52.

> > The code I wrote for "Report A"

> >      Form1.Crpe1.ReportName:= 'c:\Reports\Report A.rpt';
> >      Form1.Crpe1.ParamFields.Retrieve;
> >      Form1.Crpe1.ParamFields[0].RetrieveValues;
> >      Form1.Crpe1.ParamFields[1].RetrieveValues;
> >      Form1.Crpe1.ParamFields[0].AsDateTime:= startDate;
> >      Form1.Crpe1.ParamFields[1].AsDateTime:= endDate;
> >      Form1.Crpe1.Printer.Retrieve;
> >      Form1.Crpe1.Printer.PreserveRptSettings :=
> > [prOrientation,prPaperSize,prPaperSource];
> >      Form1.Crpe1.ConnectMethod := useConnect;
> >      Form1.Crpe1.Connect.Password := '_password_';
> >      Form1.Crpe1.Output := toWindow;
> >      Form1.Crpe1.Execute;

> Upon further thought, I have had problems with CR where paths contain
spaces.
> They seem particularly severe with W98.

> ParamFields.Retrieve clears the values, so, at best,
> ParamFields[0].RetrieveValues does nothing, and, at worst might cause your
> crash.

> Printer.Retrieve should not be necessary, since you don't change any
settings,
> but I
> don't think it does any harm.

> After .ConnectMethod I think you have to use .ConnectRetrieve, though this
is
> not tested since I use the LogON.

> John Pierce

Re:Crystal VCL causes system crash!!


Hello,

(After I fixed up those connect.retrieve problems)

Ok that solved the problem for that report however I was still having
problems with a couple (not all) of my non-parametrized reports causing a
system crash on execution from a delphi app. After some analysis I noted
that the reports that were crashing all had the option "File|Save Data with
Report" turned off in Crystal Reports.

These non-param fields reports caused the system to crash on execution of
Crpe1.Execute when these steps were followed..

1.  run the report from delphi,
2.  close the report window
3.  re run the same report.  or run another report followed by running the
initial report again.
4. observe system crash :-(

This only causes a system crash on the second execution of the same report
from a single instance of the application.

So I set the non parametrized reports to File|"Save Data with Report" from
within Crystal Reports.  Then they all worked.  it seemed that the problem
was fixed!!

However,  after some testing I noticed that one of my parametrized reports
crashes in the following scenario.

1.  run the report with one set of parameters (set in code)
2.  WITHOUT closing the first window,  run the report again using a second
set of parameters (also set in code)
3.  this is quickly followed by the quick crash of the *indestructible* OS
(win2000).

Does anyone know of this problem?  It suggests to me that the VCL is doing
some BAD things to space reserved for the OS.   Any ideas?

Thanks,

Pat Bundon

Quote
"Pat Bundon" <pbun...@vigil-inc.com> wrote in message news:395cedbf@dnews...
> Thanks John,

> I thought about it a little more clearly this morning and was able to find
> an example which also reminded me to use Connect.Retrieve. Using that
before
> Crpe1.Connect.Password is set seems to solve the problem.
> I also removed the paramfield[i].retrieve lines.   Seems to work well now.

> Thanks for all the pointers.  You've been a terrific help!

> Pat Bundon

> for reference, when was crashing the system it always happened on
execution
> of Crpe1.Execute;

> "John Pierce" <jpie...@healthplanning.com> wrote in message
> news:395CE02B.A6BA5B2@healthplanning.com...

> > Pat Bundon wrote:

> > > Hello,

> > > I am getting an abrupt system crash and reboot when I try to access a
> > > Crystal Report (say Report A) through the Seagate Crystal VCL.

> > > "Report A" contains parameter fields which are passed values through
the
> > > vcl.  Other reports with parameters work fine, and this report worked
> fine
> > > a few days ago.

> > > I am running CrystalReports 7.0.15,  Delphi 4 update3  with Crystal
VCL
> > > 7.52.

> > > The code I wrote for "Report A"

> > >      Form1.Crpe1.ReportName:= 'c:\Reports\Report A.rpt';
> > >      Form1.Crpe1.ParamFields.Retrieve;
> > >      Form1.Crpe1.ParamFields[0].RetrieveValues;
> > >      Form1.Crpe1.ParamFields[1].RetrieveValues;
> > >      Form1.Crpe1.ParamFields[0].AsDateTime:= startDate;
> > >      Form1.Crpe1.ParamFields[1].AsDateTime:= endDate;
> > >      Form1.Crpe1.Printer.Retrieve;
> > >      Form1.Crpe1.Printer.PreserveRptSettings :=
> > >  [prOrientation,prPaperSize,prPaperSource];
> > >      Form1.Crpe1.ConnectMethod := useConnect;
> > >      Form1.Crpe1.Connect.Password := '_password_';
> > >      Form1.Crpe1.Output := toWindow;
> > >      Form1.Crpe1.Execute;

> > Upon further thought, I have had problems with CR where paths contain
> spaces.
> > They seem particularly severe with W98.

> > ParamFields.Retrieve clears the values, so, at best,
> > ParamFields[0].RetrieveValues does nothing, and, at worst might cause
your
> > crash.

> > Printer.Retrieve should not be necessary, since you don't change any
> settings,
> > but I
> > don't think it does any harm.

> > After .ConnectMethod I think you have to use .ConnectRetrieve, though
this
> is
> > not tested since I use the LogON.

> > John Pierce

Re:Crystal VCL causes system crash!!


Solution

Call Crpe.CloseJob after each Crpe.Execute.   Looks like a resource handling
problem if you do not use CloseJob and try to run many reports
simultaneously through Delphi.

Thanks everyone for the help!

Pat B

Re:Crystal VCL causes system crash!!


If your report is going to the printer, you should put
while not crpe1.printended do
    Application.ProcessMessages;

before the CloseJob;

There seems to be a bug in crpe that causes it to abort with an error
instead of retrying when told to close a running printjob.

John Pierce

Other Threads