在 Windows 应用程序中从报表服务器访问报表服务(远程模式)时出错 [英] Error while accessing report service(remote mode) from Report server with in a windows application

查看:44
本文介绍了在 Windows 应用程序中从报表服务器访问报表服务(远程模式)时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从报表服务器访问报表时出现以下错误.我正在使用 Windows 应用程序访问我的报告.这是我的代码:

I got following error while accessing report from report server . I am using a windows application to access my report.This is my code:

private void rptviewer_Click(object sender, EventArgs e)
        {
            string reportName = "Crime_Traking_Report";
            string reporturl = @"http://13.800.91.136/ReportServer";
            string reportpath = @"/iSROReportsRK7/";
            reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;
         reportViewer1.ServerReport.ReportServerCredentials = new ReportServerCredentials("isro", "password1209083$", "Rocket");


            try
            {
                reportViewer1.ServerReport.ReportServerUrl = new Uri(reporturl);
            }
            catch (UriFormatException)
            {
                Console.WriteLine("Bad Url format");
            }
            reportViewer1.ServerReport.ReportPath = reportpath + reportName;
            reportViewer1.ProcessingMode = ProcessingMode.Remote;
            reportViewer1.ServerReport.Refresh();

        }


        public  class ReportServerCredentials : IReportServerCredentials
        {
            private string _UserName;
            private string _PassWord;
            private string _DomainName;

            public ReportServerCredentials(string UserName, string PassWord, string DomainName)
            {
                _UserName = UserName;
                _PassWord = PassWord;
                _DomainName = DomainName;
            }




            public System.Security.Principal.WindowsIdentity ImpersonationUser
            {
                get { return null; }
            }

            public ICredentials NetworkCredentials
            {
                get { return new NetworkCredential(_UserName, _PassWord, _DomainName); }
            }
            public bool GetFormsCredentials(out Cookie authCookie, out string user,out string password, out string authority)
            {
                authCookie = null;
                user = password = authority = null;
                return false;
            }

        }

我得到的错误是:错误 1 ​​属性或索引器Microsoft.Reporting.WinForms.ServerReport.ReportServerCredentials"不能分配给——它是只读的
错误 2 无法将类型Daily_Crime_Traking.Form1.ReportServerCredentials"隐式转换为Microsoft.Reporting.WinForms.ReportServerCredentials"

Error i got is :Error 1 Property or indexer 'Microsoft.Reporting.WinForms.ServerReport.ReportServerCredentials' cannot be assigned to -- it is read only
Error 2 Cannot implicitly convert type 'Daily_Crime_Traking.Form1.ReportServerCredentials' to 'Microsoft.Reporting.WinForms.ReportServerCredentials'

我尝试通过将类名更改为 CustomServerCRedintials 以避免 nameConflict 问题,然后也是我想要解决此问题的相同类型的错误.

I tried by changing the class name to CustomServerCRedintials inorder to avoid a nameConflict issue then also the same kind of Error what i want to do to solve this issue.

推荐答案

我用这个来设置凭据

reportViewer1.ServerReport.SetDataSourceCredentials({ new DataSourceCredentials {
    Name = _DataSourceName,
    UserId =_UserName,
    Password = _PassWord
} })

请参阅:ServerReport.SetDataSourceCredentials 方法

DataSourceCredentials 成员
报告服务报告使用 SQL 身份验证的查看器

这篇关于在 Windows 应用程序中从报表服务器访问报表服务(远程模式)时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆