问题描述:

Okay, I'm having lots of troubles with RDLC's, so going back to RDL reports. Now, I understand that i need a reporting server for reports to run, and then on the front-end I can use report viewer and select path to the report. I'm using my local computer, so ned to make it work locally at least. I do not understand how to install reporting server locally. I found couple of MSDN articles on the web, but they are overly complicated. Is there a simple tutorial on how to use RDL reports from ithin a webpage?

网友答案:

SQL Server Reporting Services (SSRS) is installed as part of Microsoft SQL Server. You need to use SQL Server installation media to install SSRS. You can install install only SSRS without other SQL Server components, but you will need to have a SQL Server to store the databases where SSRS keeps its data.

I don't have much experience with the lower end options, but SSRS is available with "SQL Server Express with Advanced Services"

网友答案:

I presume you are familiar with asp.net. Create a new asp.net app or website. Add reference of Microsoft.Reporting.WebForms (right click --> add reference)

Then add this in your Page directive

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

Then you should be able to use the reportviewer control as

<rsweb:ReportViewer ID="rptOne" runat="server" AsyncRendering="true" ProcessingMode="Remote" ShowPrintButton="false" ShowPageNavigationControls="true" ShowParameterPrompts="false" ShowBackButton="true" ShowExportControls="true" Height="1000px" Width="1000px" SizeToReportContent="false"> </rsweb:ReportViewer>

(Obviously, you dont need to set all the properties i did.)

You can then set your url in the code behind

        Me.rptOne.ServerReport.ReportServerUrl = New System.Uri(sUrl)
    Me.rptOne.ServerReport.ReportPath = sPath

Another example here

网友答案:

Not a lot of documentation the reports are useful but more difficult then SQL Server Reporting Services (SSRS) make a class pass the entire report viewer in this code snippet rpt = the Report viewer passed in on the heap: rpt.LocalReport.DataSources.Clear();

    Microsoft.Reporting.WebForms.ReportDataSource rptdTitle = new Microsoft.Reporting.WebForms.ReportDataSource();
    rptdTitle.Name = "DataSet1";
    rptdTitle.Value = dt2;
    rpt.LocalReport.DataSources.Add(rptdTitle);

    Microsoft.Reporting.WebForms.ReportDataSource rptdTop = new Microsoft.Reporting.WebForms.ReportDataSource();
    rptdTop.Name = "DataSet2";
    rptdTop.Value = dt1;
    rpt.LocalReport.DataSources.Add(rptdTop);


    Microsoft.Reporting.WebForms.ReportDataSource rptDate = new Microsoft.Reporting.WebForms.ReportDataSource();
    rptDate.Name = "DataSet3";
    rptDate.Value = dsTableDate;
    rpt.LocalReport.DataSources.Add(rptDate);



    Microsoft.Reporting.WebForms.ReportDataSource rptTable = new Microsoft.Reporting.WebForms.ReportDataSource();
    rptTable.Name = "DataSet4";
    rptTable.Value = dtReport;
    rpt.LocalReport.DataSources.Add(rptTable);

    rpt.LocalReport.ReportPath = System.Web.HttpContext.Current.Server.MapPath(@"~\Reports\rptPeriodTotals.rdlc");

    rpt.LocalReport.Refresh();
相关阅读:
Top