从本地应用程序访问SSRS服务器报告

时间:2014-01-21 04:41:26

标签: asp.net reporting-services

我已在服务器中部署了SSRS报告。我是否可以从本地Web应用程序访问该报告。我已经在web.config中提供了服务器的凭据。但仍然没有显示报告,它显示了一些错误,如Cannot create a connection to data source 'DataSource1'. (rsErrorOpeningConnection)

当我在服务器中托管相同的应用程序时,它工作得非常好。

有谁能告诉我为什么我无法从本地系统访问报告?

1 个答案:

答案 0 :(得分:1)

这不是我的代码,但理想情况下,您只需要做。我记得有时候在以前的一个项目中成功使用它

private void ShowReport()
{
    try
    {
        string urlReportServer = "http://sqlDBServer//Reportserver";
        rptViewer.ProcessingMode = ProcessingMode.Remote; // ProcessingMode will be Either Remote or Local
        rptViewer.ServerReport.ReportServerUrl = new Uri(urlReportServer); //Set the ReportServer Url
        rptViewer.ServerReport.ReportPath = "/ReportName"; //Passing the Report Path                

        //Creating an ArrayList for combine the Parameters which will be passed into SSRS Report
        ArrayList reportParam = new ArrayList();
        reportParam = ReportDefaultPatam();

        ReportParameter[] param = new ReportParameter[reportParam.Count];
        for (int k = 0; k < reportParam.Count; k++)
        {
            param[k] = (ReportParameter)reportParam[k];
        }
        // pass crendentitilas
        //rptViewer.ServerReport.ReportServerCredentials = 
        //  new ReportServerCredentials("uName", "PassWORD", "doMain");

        //pass parmeters to report
        rptViewer.ServerReport.SetParameters(param); //Set Report Parameters
        rptViewer.ServerReport.Refresh();
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

参考:http://www.codeproject.com/Articles/675762/Call-SSRS-Reports-by-using-Csharp