Using Microsoft Reports (.rdlc) in a 3-Tier app

为君一笑 提交于 2019-12-04 19:52:27
Alex Essilfie

As I said earlier, I do not do ASP so I don't know how resources used in such projects are deployed.
In WinForms projects, there are generally two options for deploying reports:

  • Embedded Resource (included in the output executable)
  • Content (Copied to the output directory)

Here is code that illustrates both procedures. It is an extract from my answer to your previous question.

With rptVwr.LocalReport
    'use this if the report is embedded in the project                     '
    'the name is of the following format [ProjectNamespace].[ReportName]   '
    .ReportEmbeddedResource = "ObjectReport.SampleReport.rdlc"

    'use the ReportPath if the report is stored somewhere else             '
    .ReportPath = "C:\Path\to\your\report" 'For demonstration purposes only'
End With

As you can see, when the report is embedded, you just assign the report as I illustrated in the accompanying comment.

I think, based on the nature of your project, you should set the report's Build Action in the Properties window as an embedded resource. That way, it can be accessed from wherever it is deployed.


Edit 1
I was looking through the MSDN Library and I found this article which covers server reports. Just scroll to the code section. I think it has what you're looking for.

There was also an article on CodeProject which covers your request extensively.

After skimming through, it appears you have to do the following:

  1. Set the report viewer's ProcessingMode property to Server.
  2. Enter the path (url) of the report in the ServerReport.ReportServerUrl property.
  3. Enter the location of the report in the ServerReport.ReportPath property.


Conclusion:

When deploying desktop applications, use the LocalReport property of the ReportViewer control and set the ProcessingMode to Local.
When deploying web-based projects use the ServerReoprt property of the ReportViewer control and set the ProcessingMode to Remote.

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