简体   繁体   English

在Reporting Service报表上设置数据源

[英]Setting datasource on a Reporting Service report

i have a drop down list contains the name of reports and each report have a value (1,2,3...) and i have a popup window that appears when user click on view report button this popup is a web page that contains the report viewer ,,in cs of this popup page i have a swtich that takes int which is the value of the report eg.if i want to display the first report so i chose the first one in the drop down list and the selected value is 1 and it is passed to the page that contains the report viewer in a session variable and pass it to switch then case 1;........break so i want to know how to create an object of type report and bind it to the report viewer in each case ,,i have made something like that but i used crystal reports and crystal report viewer which has a 我有一个包含报告名称的下拉列表,每个报告都有一个值(1,2,3 ...),并且我有一个弹出窗口,当用户单击“查看报告”按钮时出现,该弹出窗口是一个包含以下内容的网页报告查看器,在此弹出页面的cs中,我有一个带int的swtich,它是报告的值,例如,如果我想显示第一个报告,那么我在下拉列表中选择了第一个报告并选择了值是1,它被传递到包含会话查看器中的报告查看器的页面,并将其传递给开关,然后切换到案例1; ........ break,所以我想知道如何创建类型为report的对象,在每种情况下,将其绑定到报表查看器,我做了类似的事情,但是我使用了Crystal Report和Crystal Report Viewer,它具有

CrystalReportViewer1.ReportSource = rpt;
CrystalReportViewer1.DataBind();

and i have a report object 我有一个报告对象

rpt.SetDataSource(dt);        
ReportDocument rpt;

but i cant do anything like that when i used reporting service 但是当我使用报告服务时我无法做类似的事情

so please help 所以请帮忙

thanks 谢谢

You are talking about the Microsoft SQL Server Reporting Services (SSRS), right? 您是在谈论Microsoft SQL Server Reporting Services(SSRS),对吗?

The approach is a bit different than with Crystal - basically, SSRS is by default a server-based reporting engine, eg your application (Winforms or ASP.NET or whatever it is) doesn't actually render the report locally, and also it doesn't supply the data locally. 该方法与Crystal有所不同-基本上,SSRS在默认情况下是基于服务器的报告引擎,例如,您的应用程序(Winforms或ASP.NET或任何其他形式)实际上并未在本地呈现报告,并且它也没有不在本地提供数据。

In SSRS, this is typically handled by the report itself and on the server. 在SSRS中,这通常由报表本身和服务器上处理。 You typically only simply show the report (possibly configured with some report parameters), but all in all, the Reporting server will grab the data, format it, render the report, and your application really only shows the output in the end. 通常,您通常只显示报告(可能配置了一些报告参数),但是总而言之,报告服务器将抓取数据,对其进行格式化,呈现报告,而您的应用程序实际上仅在最后显示输出。

If you want to render a SSRS report locally, you need to have a *.rdlc file - do you have this, are you familiar with that option? 如果要在本地呈现SSRS报告,则需要有一个* .rdlc文件-是否有此文件,您熟悉该选项吗?

If you do - once you're into locally rendering the report, of course, you will also have to provide the data locally. 如果您这样做了-当然,一旦要在本地呈现报告,您还必须在本地提供数据。 If you use the ASP.NET or Winforms ReportViewer control, you can do this something like this: 如果使用ASP.NET或Winforms ReportViewer控件,则可以执行以下操作:

ReportViewer reportViewer = new ReportViewer();

reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.LocalReport.ReportPath = "Report1.rdlc"; // supply path to the RDLC file
reportViewer.LocalReport.DataSources.Add(.........)

reportViewer.RefreshReport();

Basically, you need to tell the ReportViewer control that you're dealing with local rendering, and then you need to give it the path to the RDLC file, and you can add as many data sources to the ReportViewer.LocalReport collection as you need to have for your report. 基本上,您需要告诉ReportViewer控件您正在处理本地呈现,然后需要为其提供RDLC文件的路径,并且可以根据需要向ReportViewer.LocalReport集合添加尽可能多的数据源。有你的报告。

Does that help at all? 这些帮助有用? Otherwise, please clarify your question a bit more. 否则,请进一步澄清您的问题。

See a VB.NET sample of retrieving data for a local report from a web service here . 在此处,请参见从Web服务检索数据的VB.NET示例以获取本地报告。

I tried doing this a while ago. 我试过一阵子了。 I gave up because it wasn't that important, but my idea was this: 我放弃了,因为那并不重要,但是我的想法是这样的:

  1. Use web service to create a new datasource 使用Web服务创建新的数据源
  2. Use the web service to change the data source on the report 使用Web服务更改报告上的数据源
  3. Render the report in ReportViewer 在ReportViewer中呈现报告
  4. Switch DataSource back to original using web service. 使用Web服务将DataSource切换回原始状态。

My knowledge of ssrs is limited, but might be worth a shot. 我对ssrs的了解有限,但可能值得一试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用报告服务将报告导出为csv格式? - Export report into csv format using reporting service? 使用SQL Server报告服务在单个报告中使用两个数据集 - Using two datasets in a single report using SQL server reporting service 如何使用SQL Server报表服务引用报表中的计算字段 - How to reference calculated fields in a report using SQL Server Reporting Service 在sqlserver报表服务的主报表中的子报表顶部添加行 - Add line on top of subreport in main report on sqlserver reporting service 在Microsoft SQL Reporting Service中生成报告时出错:不是有效的指示符 - Error While generating Report in Microsoft SQL Reporting Service : NOT A VALID DESIGNATOR Reporting Service部署错误-无法建立与报表服务器的连接 - Reporting Service deployment error - Connection could not be made to the report server 报告服务配置管理器无法启动当前报告服务器 - SSRS - Reporting service configuration manager unable to start currect report server - SSRS 如何获取报表在SQL Server Reporting Services 2005中使用的数据源 - How do you get the DataSource that a report uses in SQL Server Reporting Services 2005 如何在报表服务器Web服务URL中启用“高级”选项(Reporting Service配置管理器) - How to ENABLE the Advance option in Report Server Web Service URLs (Reporting Service Configuration Manager) SSRS报告报告设计器 - SSRS reporting report designer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM