locked
How to catch reportviewer's time-out error message? RRS feed

  • Question

  • User1240375281 posted

    When my report has too much data, it will display "time out" error message. But I want to catch it and display with more friendly message.

    So I add reportViewer.ReportError += viewReport_ReportError; event. But it failed to display ErrorLabel text. Is there anyone know how to display that?

     It always display the timeout error message and parameter panel is hidden. ErrorPanel and ErrorLabel are hidden too.

      protected void viewReport_ReportError(object sender, ReportErrorEventArgs e)
            {
                if (e.Exception.Message.Contains("time-out"))
                    ErrorLabel.Text = "test";
                else
                    ErrorLabel.Text = "error";
    
                ErrorLabel.Visible = true;
                ErrorPanel.Visible = true;
                Panel1.Visible = true;
                radPanelBar.Visible = true;
                reportViewer.Visible = false;
                e.Handled = true;
            }

    <asp:Panel ID="ErrorPanel" runat="server" Height= "30px" Width="100%" Visible="false" Style="left: 0px; ; top:0px;" Wrap="False" BackColor="WhiteSmoke">
                <asp:Label ID="ErrorLabel" runat="server" Style="" Width="100%" Font-Names="Verdana,Sans-Serif" Font-Size="10pt"></asp:Label>
            </asp:Panel>
            <rsweb:ReportViewer ID="reportViewer" runat="server" cssClass="ReportStyle" AsyncRendering ="false"
                Height="700px" Width="100%" ProcessingMode="Remote"
                ShowParameterPrompts="False" OnDrillthrough="reportViewer_Drillthrough"
                Font-Names="Arial" BackColor="#CED8EE" BorderStyle="None" Font-Size="10pt"
                InternalBorderWidth="0px" ShowFindControls="False">
            </rsweb:ReportViewer>

    Thursday, May 9, 2013 4:01 AM

All replies

  • User-8475372 posted

    Dear User, 

    If you want to take out "timeout" constraint from the report server. Here is the process : (Ideally, that would take out the possibility of your coding issue that you are facing)

    http://geekswithblogs.net/ssrs/archive/2009/10/30/steps-to-resolve-ssrs-timeout-issues.aspx

    Monday, May 13, 2013 1:40 AM
  • User1240375281 posted

    Hi Srikanth,

    Thanks, but what I want to do is to catch the "timeout" error message and display the error message in a more friendly way. So I don't want to take out the timeout error.

    I also found from msdn with below link, it says we cannot catch reportviewer’s error message from client side java script, is it true? 

    http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/f59e36b4-07a5-4471-9ddd-10897014db4c/

    Alex

    Monday, May 13, 2013 1:49 AM
  • User-8475372 posted

    Alex,

    Ok. In your code where you generate report (refresh), try to put it inside the "try and catch block", inside catch block catch and show the message. 

    try{

    ........

    reportViewer.ProcessingMode = ProcessingMode.Local;
    reportViewer.LocalReport.SetParameters(parameters);
    reportViewer.LocalReport.Refresh();

    }

     catch (Exception ex)
          {
             lblError.Text = ex.Message;//Or you can use javascript alert message and show it here. 
          }
    Monday, May 13, 2013 2:28 AM
  • User1240375281 posted

    Hi,

    I have tried add this try catch as your suggested, but it cannot trigger that catched codes. I don't know whether it is because of my codes.

     protected void viewButton_Click(object sender, EventArgs e)
            {
                try
                {
                    if (!ParamPanel.IsValid) // Display error message if it is not valid
                    {
                        reportViewer.ShowReportBody = false;
                        ErrorPanel.Visible = true;
                        ErrorLabel.Text = ParamPanel.ErrorText;
                    }
                    else
                    {
                        reportViewer.ServerReport.Refresh();
                        reportViewer.ShowReportBody = true;
                        ErrorPanel.Visible = false;
                    }
                }
                catch (Exception ex)
                {
                    WebService.LogMessage(ex.ToString(), "ReportWeb.ViewReport.viewButton_Click()", true);
                }
            }

    Alex

    Monday, May 13, 2013 5:30 AM