This is a migrated thread and some comments may be shown as answers.

Attempted to divide by zero.

8 Answers 1002 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Koen L
Top achievements
Rank 1
Koen L asked on 27 Sep 2011, 07:18 AM
When printing a report i sometimes get this error.
Can you please give me a direction where to start?

Attempted to divide by zero.

---EXCEPTIONS----------

[DivideByZeroException]
Attempted to divide by zero.


---STACK TRACE----------

at System.Drawing.Printing.PageSettings.get_HardMarginX()
at Telerik.Reporting.Processing.ReportPrintDocument.OnBeginPrint(PrintEventArgs e)
at System.Drawing.Printing.PrintDocument._OnBeginPrint(PrintEventArgs e)
at System.Drawing.Printing.PrintController.Print(PrintDocument document)
at System.Drawing.Printing.PrintDocument.Print()
at Telerik.Reporting.Processing.ReportProcessor.PrintReport(IReportDocument reportDocument, PrinterSettings printerSettings)
at CLGroup.Intranet.Purchase.Reporting.RepBolist.PrintDocument(Int32 branchId, PersonalizationFeatureType feature, Report report)
at CLGroup.Intranet.Purchase.Reporting.RepBolist.Send_Click(Object sender, EventArgs e)

8 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 27 Sep 2011, 09:34 AM
Hello Koen L,

There is no reason why such error would be thrown randomly except if an expected parameter returns NULL or DbNull for some reason. If you can isolate the problem in a runnable project, please open a support ticket, zip and attach it there, so we can review it and provide more info.

Greetings,
Steve
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Koen L
Top achievements
Rank 1
answered on 27 Sep 2011, 12:33 PM
If that would be the reason then it would be easy to solve the problem.

When the user gets this error and requests the same report again it works just normal.
So it would be hard to believe that the incomming data has been changed between the time of error and the next request for the same report.

But lets assume that there is a field with a null value. Can't we see what field it is in the errormessage?
0
Steve
Telerik team
answered on 27 Sep 2011, 02:07 PM
Hello Koen L,

Try running your project in debug mode with first chance exceptions turned on. This way Visual Studio should break when the exception occurs, so you can pinpoint the source of the problem, or at least you can provide us with a complete stack trace, in case the exception is not thrown by your code.
Additionally can you confirm that you are able to reproduce the problem on your end or does this only happen to some specific user? If it is reproducible, then please open a support ticket with a sample project.

All the best,
Steve
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jamie
Top achievements
Rank 1
answered on 03 Oct 2011, 04:29 PM
I also receive this error when trying to print and it seems very intermittent also.  I have been unable to track down the cause.
0
PAGCA
Top achievements
Rank 1
answered on 04 Oct 2011, 06:28 PM
This may or may not be related. I have this code in a textbox on the report.

=IIf(priorTotal <> 0,(catTotal-priorTotal)/priorTotal,"zero")

It produces a divide by zero error every time even though there should be no division when priorTotal is zero..
0
Steve
Telerik team
answered on 05 Oct 2011, 10:17 AM
Hi guys,

@Don: This behavior is by design and you can find more info in the following forum thread.

@Jamie: Generally intermittent errors are the hardest to track down and that is why if you continue to have problems, we would appreciate if you take the time to narrow down the steps that cause the issue or provide us with a runnable sample which reproduces the error.

Kind regards,
Steve
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Derrick
Top achievements
Rank 2
answered on 26 Jan 2012, 04:19 PM
I have the same problem as well.  The IIF() is not working correctly!!!
0
Steve
Telerik team
answered on 26 Jan 2012, 05:35 PM
Hi Derrick,

Did you try the suggestion from the link in the previous post? Why do you think the IIF() function does not work correctly? Can you elaborate how you expect it to work and provide arguments? If you are having problems with certain expression, we would need it in order to advise how to address it.

Kind regards,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Tags
General Discussions
Asked by
Koen L
Top achievements
Rank 1
Answers by
Steve
Telerik team
Koen L
Top achievements
Rank 1
Jamie
Top achievements
Rank 1
PAGCA
Top achievements
Rank 1
Derrick
Top achievements
Rank 2
Share this question
or