on 12-05-2011 11:52 AM
*
We are using .NET SDK for Crystal Reports 2008 and Report Document Object Model \ API.
Printing throws error but preview works fine launching an empty report viewer.
*
Message = Attempted to divide by zero.
StackTrace =
at CrystalDecisions.Shared.PrintingHelper.PrintPage(PrintPageEventArgs e, PageObject page,
PrintLayoutSettings layoutSettings, Int32& currentPageNumber, Int32& currentHorizontalPageNumber)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintPageEventHandler(Object sender, PrintPageEventArgs e)
at System.Drawing.Printing.PrintDocument.OnPrintPage(PrintPageEventArgs e)
at System.Drawing.Printing.PrintDocument._OnPrintPage(PrintPageEventArgs e)
at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
at System.Drawing.Printing.PrintController.Print(PrintDocument document)
at System.Drawing.Printing.PrintDocument.Print()
at CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)
at CREngine_2008.CCRPEngine_2008.Print()
This error is only faced when there are no records returned from the binded stored procedure.
The report has sub-reports present.
Main Report has "Suppress Printing if No Records" checked, but the sub reports do not have this checked ?
Could this be the problem
Any thoughts are appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check if the report has a fromula against the data returned by the stored proc.
the formula is more likely to fail when no data is returned by the stored proc.
See if below kbase helps,
[1214596 - Err Msg: "Division by zero" with formula containing IIF function |http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313334333533393336%7D.do]
Thanks,
Bhushan.
Hi ,
Many thanks for your response.
There are no division operator used in my formulas.
I have also handled all possible exception catches , but the exception is captured in .NET standard Exception (Exception handler)
catch (LogOnException e)
catch (DataSourceException e)
catch (SubreportException e)
catch (ParameterFieldException e)
catch (FormulaException e)
catch (FormattingException e)
catch (EngineException e)
Try following test.
- Remove the subreport from the report, see if it reproduces the issue.
- Supress all the sections. print the report.
- Now unsupress one section at a time, and print report, observe the behaviour.
- follow the procedure untill all the sections are unsupressed.
At the end of this test, we will know which section is causing the error, then reevaluate that particluar section.
- Bhushan.
Crystal Reports 2008 and Report Document Object Model \ API.
- Are you referencing the craxDDrt.dll and crviewer.dll in your project? If not, what CR files are you referencing?
Ludek
Follow us on Twitter http://twitter.com/SAPCRNetSup
Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]
- Are you referencing the craxDDrt.dll and crviewer.dll in your project? If not, what CR files are you referencing?
NO
<Reference Include="CrystalDecisions.CrystalReports.Engine, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
<Reference Include="CrystalDecisions.Enterprise.Framework, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
<Reference Include="CrystalDecisions.Enterprise.InfoStore, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
<Reference Include="CrystalDecisions.ReportSource, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
<Reference Include="CrystalDecisions.Shared, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
<Reference Include="CrystalDecisions.Windows.Forms, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
Hi LUDEK UHER,
SAP Crystal Reports 2011 Release Notes -- 07/12/2010
SAP Crystal Reports General Issues
Functional Correctness
ADAPT00264642
Blank pages are printed when the "Suppress printing if no records" option is enabled
If a user attempts to print from an empty report, or attempts to print an empty selection from a report, a blank
page is printed, even when the "Suppress printing if no records" option is enabled.
Does this problem exiist in Crystal Report 2008 ?
Here is an extract from the ADAPT:
...the conclusion is to postpone to future as this requires some significant changes.
There is no word re. definition of "future", however the feeling I get from the rest of the notes in the ADAPT is that there is significant hesitation re. implementing the changes required due to the risk of adding significant instabilities along with the fix... E.g.; no ETA.
Suggested work-around in the ADAPT:
...check for number of records returned, the developer can check this value and simply not call the PrintToPrinter() api.
Code that would let you check the record count is documented in KB [1471477 - Using the RAS SDK for VS .NET, how to determine number of data rows returned to a report?|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333433373331333433373337%7D.do]
Another KB that may help:
[1487765 - How to stop a report with no data from printing|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333433383337333733363335%7D.do]
- Ludek
Edited by: Ludek Uher on Dec 7, 2011 8:00 AM
Hi Ludek,
Thank for your reply much appreciated.
We are using .NET SDK We set formulas , parameters on the fly , hence we cannot use Refresh() as it would reset parameter and formula set.
1487765 - How to stop a report with no data from printing
Use the following code for CR for .NET SDK:
If crReportDocument.Rows.Count > 0 Then crReportDocument.PrintToPrinter(1, False, 0, 0)End if
At point in time the ROWS property of the reportdocument will be populated ?
Thanks
Ilan
Hi Ludek,
Many thanks for the replies.
I mispelled my last reply.
Currently PrinttoPrinter method call results in firing the database query ( Stored Procedure call)
I cannot call REFRESH, as it resets the parameter i set after loading the report.
What method should i call , to fire the database query to get the database query fired, but not print it.
If i can fire database query before printing, i can access the count of ROWS attribute of the ReportDocument and
work around the problem ?
Use .Refresh before setting the parameters. At that point, .Refresh should only drop any "Saved Data" that may be with the report, but no query to the DB should be issued. Then set that parameters.
From the SAP Crystal Reports .NET API Guide:
Removes saved data. This causes fresh data to be loaded when the report is subsequently viewed.
- Ludek
Hi Ludek,
Many Thanks that worked.
1) Load Report
2) Refresh
3) Set Parameters
4) If we make an attempt to access the Rows Attribute ( m_RptDocument.Rows.Count )
on the Report Document, Crystal Report seeing data is not populated fires the query back to the database.
5) You check the count and decide to all PrintToPrinter.
Can i sneak another one please ?
Is there way we can know if a reportdoucment has "Suppress Printing if no records" is turned on / off
via .NET SDK of Crystal Report 2008.
I tried the property "ReportOptions" on the Report Document bt no luck?
Thanks
Ilan
Edited by: Ilanthendral on Dec 8, 2011 4:54 PM
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.