none
Handling database restore in SSRS report

    Question

  • I have a report that references a shared data source.  The connection string contains Intitial Catalog=MyDatabase.  When MyDatabase is in the middle of a restore it would be nice to give the users of the report a message like "Hey, the report will be available shortly, don't call the helpdesk, it's not the end of the world... yet" rather than

    "An error has occurred during report processing. (rsProcessingAborted)
    Cannot create a connection to data source 'DataSource1'. (rsErrorOpeningConnection)
    For more information about this error navigate to the report server on the local server machine, or enable remote errors"

    Related, but a little different, is the issue when a data source does not include an Initial Catalog specification but more than one database in the data set.  Consider this example.

    SELECT *
      FROM MyDatabase.dbo.TheTable
    		  JOIN AnotherDatabase.dbo.AnotherTable ON ...
    If either MyDatabase or AnotherDatabase is unavailable it would be nice to display the same kind of message.

    SSRS seems to lack basic error handling like this.  Any options?

    Wednesday, April 03, 2013 2:20 PM

Answers

  • Hi Mateoc15,

    The report server and report manager are code-behind and it is not supported to customize the error/exception messages for them.

    I would suggest you submitting a wish at https://connect.microsoft.com/sql.

    Connect site is a connection point between you and Microsoft, and ultimately the larger community. Your feedback enables Microsoft to make software and services the best that they can be, and you can learn about and contribute to exciting projects.

    Regards,


    Mike Yin
    TechNet Community Support

    Wednesday, April 10, 2013 10:05 AM

All replies

  • There is two options. You can modify in reportviewer.aspx, add right before </form>

    <script type="text/javascript">
    var rptDivString=document.getElementById('ReportViewerControl_ctl10_NonReportContent').innerHTML;
    //alert( rptDivString );
    var numPermError = rptDivString.search(/permissions/i);
    if (numPermError>0)
    {
    var docTitle = document.title;
    var reportName = docTitle.substr(0,docTitle.length-16);
    alert('Reporting Services permissions error in report: ' +  reportName );
    }
    </script>
    


    Please Mark posts as answers or helpful so that others can more easily find the answers they seek.

    • Proposed as answer by Sachi_SG Wednesday, April 03, 2013 4:16 PM
    Wednesday, April 03, 2013 4:16 PM
  • Next options is to use to ReportViewer javascript .

    // This replaces a method in the ReportViewer javascript. If Microsoft updates 
    // this particular method, it may cause problems, but that is unlikely to 
    // happen.The purpose of this is to redirect the user to the error page when 
    // an error occurs. The ReportViewer.ReportError event is not (always?) raised 
    // for Remote Async reports
    function OnReportFrameLoaded() {
        this.m_reportLoaded = true;
        this.ShowWaitFrame(false);
    
        if (this.IsAsync)
        {
            if(this.m_reportObject == null)
            {
                window.location = 
                    '<%= HttpRuntime.AppDomainAppVirtualPath %>/Error.aspx';
            }
            else
            {
                this.m_reportObject.OnFrameVisible();
            }
        }
    }
    RSClientController.prototype.OnReportFrameLoaded = OnReportFrameLoaded;
    

    Original code would look as below.

    function OnReportFrameLoaded()
    {
        this.m_reportLoaded = true;
        this.ShowWaitFrame(false);
    
        if (this.IsAsync && this.m_reportObject != null)
            this.m_reportObject.OnFrameVisible();
    }
    RSClientController.prototype.OnReportFrameLoaded = OnReportFrameLoaded;
    


    Please Mark posts as answers or helpful so that others can more easily find the answers they seek.

    • Proposed as answer by Sachi_SG Wednesday, April 03, 2013 4:18 PM
    Wednesday, April 03, 2013 4:18 PM
  • Nasty... really nasty.  Thanks Sachi.

    This just seems 10x more difficult than it should have to be.  I hate the idea of modifying code that could potentially be overwritten by patches, upgrades, etc.  Are there any other ways to handle from within an individual report or otherwise, something not at the server level?

    Wednesday, April 03, 2013 6:01 PM
  • It is not nasty :) ..

    Reportserver is very flexiable. And it is ok to change this kind of code.


    Please Mark posts as answers or helpful so that others can more easily find the answers they seek.

    Wednesday, April 03, 2013 8:13 PM
  • Changing any of the internal Microsoft aspx pages or javascript files is not supported.

    And it is not recommended either - if you get something wrong you could potentially have to reinstall reporting services. 



    Thanks! Josh

    Wednesday, April 03, 2013 11:18 PM
  • Hi Mateoc15,

    The report server and report manager are code-behind and it is not supported to customize the error/exception messages for them.

    I would suggest you submitting a wish at https://connect.microsoft.com/sql.

    Connect site is a connection point between you and Microsoft, and ultimately the larger community. Your feedback enables Microsoft to make software and services the best that they can be, and you can learn about and contribute to exciting projects.

    Regards,


    Mike Yin
    TechNet Community Support

    Wednesday, April 10, 2013 10:05 AM