All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
在ASP.NET中访问SQL,2005报表服务_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/16 9:31:43 Browse times: 330 Comment times: 0

在ASP.NET中访问SQL,2005报表服务_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

在ASP.NET中访问SQL 2005报表服务_[Asp.Net教程]

在ASP.NET中,有多种方法可以访问SQL 2005的报表服务。

方法一: 通过ReportView控件

首先,安装ReportView控件。如果你使用的是SQL 2000报表服务器,到这个目录去找到源码工程 C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\Samples\Applications\ReportViewer\vb and C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\Samples\Applications\ReportViewer \cs,然后自己去编译。

如果你直接使用SQL 2005的报表服务器,只要安装时选择了work station,就会自动安装上这个控件。不需要自己编译了。

在你的ASP.NET工程中,新建一个web page,加入一个ReportView控件ReportViewer1。

修改ReportServerUrl和ReportPath两个属性:

ReportServerUrl=http://ctc-bar:81/reportserver (ctc-bar是你的报表服务器的名字,我这里因为使用的是端口81,所以加上了:81)

ReportPath=/Barreports/EBCdetaillist (/Barreports/EBCdetaillist是你的报表所在路径,注意最前面的/)

现在,你已经可以使用这个报表了。运行你的程序,在ReportView的位置出现了报表,和从URL访问一抹一样。

现在,我要对报表的输入参数作些工作,我的报表里有两个时间参数,开始时间和结束时间。如果直接在文本输入框输入2007-1-1,非常不方便。我希望从web page上加一个日期选择的控件来代替直接输入日期。

这需要两步:

1 将ShowParameterPrompts设置为false. 即关闭报表服务器提供的参数输入区域。

2 在web page上增加START DATE和END DATE两个日期控件,和一个VIREW REPORT的按钮。

在VIREW REPORT按钮的CLICK事件中,将日期控件的值用SetParameters方法传递给服务器。类似于

Parameters[0] =

Parameters[1] =

DateTime StartDate = System.Convert.ToDateTime(TextBoxStartDate.Value);DateTime EndDate = System.Convert.ToDateTime(TextBoxEndDate.Value);ReportParameter[] Parameters = new ReportParameter[2];new ReportParameter("startdate", StartDate.ToShortDateString());new ReportParameter("enddate", EndDate.ToShortDateString());this.ReportViewer1.ServerReport.SetParameters(Parameters);


网上这个地址有更加详细的讲解

http://www.dreams.idv.tw/~code6421/Doc/SqlRepSvc2.pdf

方法二: 通过调用SQL 2005的Web services

这种方法适合建立自己的报表解决方案,如改善报表参数的UI界面,提供漂亮的报表导航界面界面等。

具体可以参考下文

http://www.codeproject.com/sqlrs/SQLRSViewer.asp

来源:http://blog.csdn.net/yanwei100/archive/2007/02/25/1514008.aspx





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.