?
Solved

ReportViewer: Catch errors

Posted on 2008-11-03
10
Medium Priority
?
917 Views
Last Modified: 2012-05-05
Hi, I would like to know how I can catch errors that showup on my reportviewer web server control when for instance there is a parameter whose value was not set.
0
Comment
Question by:karakav
  • 5
  • 5
10 Comments
 
LVL 20

Expert Comment

by:Juan_Barrera
ID: 22870350
Hi,
You can you the ReportError method of the ReportViewer control. It has an 'e' argument of type ReportErrorEventArgs, which you can use to handle the error.
For example, I have a page where I use it like this:
 


Protected Sub ReportViewer1_ReportError(ByVal sender As Object, ByVal e As Microsoft.Reporting.WebForms.ReportErrorEventArgs) Handles ReportViewer1.ReportError 
If TypeOf e.Exception Is AspNetSessionExpiredException Then 
e.Handled = True 
Session.Abandon() 
FormsAuthentication.SignOut() 
Response.Redirect(FormsAuthentication.LoginUrl, True) 
Else 
e.Handled = False 
End If 
End Sub 

Open in new window

0
 
LVL 4

Author Comment

by:karakav
ID: 22874183
For my case that method doesn't catch the errors. They are still poping up directly on the control.
0
 
LVL 20

Expert Comment

by:Juan_Barrera
ID: 22874219
karakav,
Do you get the same error if you browse the repot using SSRS Report Manager? Because, if that's the case, the problem is with the report design, not with the report viewer control.
For wht you say in the first post, this may well be the situation.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Author Comment

by:karakav
ID: 22874384
Actually I don't care (excuse me for the expression) where the error is comming from, I am looking for a way  of stoping ANY error from poping up on the control.
0
 
LVL 20

Expert Comment

by:Juan_Barrera
ID: 22874429
how do you want to stop it if you don't know where is coming from?
0
 
LVL 4

Author Comment

by:karakav
ID: 22874541
Since most of exception classes inherit Exception, I was thinking it is the case for reporting services and that catching that one would be enough but I guess I am wrong. What I meant in my earlier post was that I don't want the user to see the error message. I just want to provide a generic error message.
0
 
LVL 20

Accepted Solution

by:
Juan_Barrera earned 2000 total points
ID: 22874598
But that's the problem:
If the exception comes from the ReportViewer itself. you should be able to catch it using the event handler I copied above.
But, if you keep in mind that the ReportViewer ends up being an IFrame, displaying content from other site (the Reports Server), you may guess that it's possible that the error could be in the report itself, and the Viewer won't know anything about it. Believe me, I've seen it :)
So, here it doesn't matter if the exception inherits System.Exception, the important thing is to keep in mind that tthe error can be coming from the RS.
That's why I suggested the approach of checking it through Report Manager, or, I should add now, check the RS execution log, for error.
Unfortunately, if you are really sure that the code above doesn't catch the exception. I don't really see any other way.
0
 
LVL 4

Author Comment

by:karakav
ID: 22875199
Yeah, I am pretty sure this won't catch my exceptions as I already handled those ones that might come out from other sources than the report. And I agree with you that the errors are probably coming inside the report. The problem is that I don't know how to check the report itself for errors.
0
 
LVL 20

Expert Comment

by:Juan_Barrera
ID: 22880534
Well, for starters, you should run the report through SSRS Report Mangager and see what happens.
Also, somebody must been doing the reports definitions and development, so that person should be able to debug it.
0
 
LVL 4

Author Closing Comment

by:karakav
ID: 31512786
Thanks any way.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

807 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