Opening Remote RDL with .NET Report Viewer

霸气de小男生 提交于 2019-12-08 00:31:26

问题


I store rdl's remotely in a sql server database in binary format. I would like to use the report viewer control to display the report.

This seems like a simple concept but I keep finding conflicting tutorials which have several different approaches...none of which I can get to work.

Am I right in thinking that all I need is the report viewer control to get this working? If so, how is it possible to open a remotely stored .rdl file?

I also have a variable which has the rdl content stored in a string...not sure if this helps? So either I can use this string or pull the .rdl from the db...

I am a newbie to .NET so I am not sure how to best approach this...So far I have the following:

ReportViewer r = new ReportViewer();
//pass the rdl to report viewer
r.ProcessingMode = ProcessingMode.Remote;

回答1:


You need to actually set it to Local processing mode not remote.

I've only ever loaded a RDL from a DLL not a database but I would look at the following API as it might have an overload to accept a string or you convert your string to a stream.

reportViewer.LocalReport.LoadReportDifinition

Here is the code I use to load from a DLL (might help to see in context)

Assembly assembly = Assembly.LoadFrom("MyReports.dll");
Stream stream = assembly.GetManifestResourceStream("Reports.MyReport.rdlc");
reportViewer.LocalReport.LoadReportDifinition(stream);



回答2:


Try to revise this code:

ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerCredentials = new ReportServerNetworkCredentials();
//ReportViewer1.ServerReport.ReportServerCredentials = new Rep();
ReportViewer1.ServerReport.ReportServerUrl = new Uri(@"http://PRODUCTIONDB:80/ReportServer/MexReports"); //report server
ReportViewer1.ServerReport.ReportPath = "rptMEXHEDailyReportReview1"; // rdl name


来源:https://stackoverflow.com/questions/8801284/opening-remote-rdl-with-net-report-viewer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!