日期:2014-05-20  浏览次数:21137 次

[求助]vs2005制作水晶报表遇到的问题
本人是新手,由于要求用VS2005做出水库水位信息的报表。要得到日水位、月水位、年水位的报表。要求excel导出,可以打印出来。

然后我在SQL SERVER中用存储过程如下:
ALTER PROCEDURE [dbo].[usp_hydrology_day]
(
@stcd varchar(2000),
@dt varchar(10),
  @tabname varchar(20)
)
AS
BEGIN
DECLARE @sql VARCHAR(8000)

SET @sql='
select
  b.stnm 站名,
  max(case datepart(hh,dt) when 8 then v else 0 end) [08:00],
  max(case datepart(hh,dt) when 9 then v else 0 end) [09:00],
  max(case datepart(hh,dt) when 10 then v else 0 end) [10:00],
  max(case datepart(hh,dt) when 11 then v else 0 end) [11:00],
  max(case datepart(hh,dt) when 12 then v else 0 end) [12:00],
  max(case datepart(hh,dt) when 13 then v else 0 end) [13:00],
  max(case datepart(hh,dt) when 14 then v else 0 end) [14:00],
  max(case datepart(hh,dt) when 15 then v else 0 end) [15:00],
  max(case datepart(hh,dt) when 16 then v else 0 end) [16:00],
  max(case datepart(hh,dt) when 17 then v else 0 end) [17:00],
  max(case datepart(hh,dt) when 18 then v else 0 end) [18:00],
  max(case datepart(hh,dt) when 19 then v else 0 end) [19:00],
  max(case datepart(hh,dt) when 20 then v else 0 end) [20:00],
  max(case datepart(hh,dt) when 21 then v else 0 end) [21:00],
  max(case datepart(hh,dt) when 22 then v else 0 end) [22:00],
  max(case datepart(hh,dt) when 23 then v else 0 end) [23:00],
  max(case datepart(hh,dt) when 0 then v else 0 end) [00:00],
  max(case datepart(hh,dt) when 1 then v else 0 end) [01:00],
  max(case datepart(hh,dt) when 2 then v else 0 end) [02:00],
  max(case datepart(hh,dt) when 3 then v else 0 end) [03:00],
  max(case datepart(hh,dt) when 4 then v else 0 end) [04:00],
  max(case datepart(hh,dt) when 5 then v else 0 end) [05:00],
  max(case datepart(hh,dt) when 6 then v else 0 end) [06:00],
  max(case datepart(hh,dt) when 7 then v else 0 end) [07:00],
  avg(v) 平均,
  max(v) 最高,
  min(v) 最低
from '+@tabname+' AS a inner join HY_STSC_A AS b on a.stcd in ('+@stcd+') and a.stcd = b.stcd and datediff(d,dt,'''+@dt+''')=0 group by b.stnm'

EXEC (@sql)
END



这样各个时间点的字段是字定义加上的,数据库中本来没有。我想请问高手们,如何传入参数得到需要的数据集然后在报表中显示出来。

原来做的时候,报表都不知道怎么设计。第一步添加dataset1.xsd用存储过程作为数据源,结果是报表设计看不到字段,没办法设计字段。

然后现在流行的报表是用什么做的呢?我刚在当当网上买了本《Crystal Reports 2008水晶报表从入门到精通》,结果书刚到那么薄的一本书觉得没什么用处,正想退货。请问:有什么好的参考书吗?


------解决方案--------------------
参考下:
http://topic.csdn.net/u/20090626/18/0e7d0af0-2555-479d-9cb5-84175787f2cd.html

PS:水晶报表目前确实没有什么好书,多数就是帮助文档的修改版本

你可以看看我写的这个系列,基本上也够用了,呵呵。可惜没写完~~

http://topic.csdn.net/u/20090713/18/6e14bf28-1979-4ade-9c60-aaf09284553d.html

还有精华区里的一些文章
http://forum.csdn.net/SList/DotNETReport/EssentialList