当前位置: 代码迷 >> .NET报表 >> 水晶报表的数据显示有关问题
  详细解决方案

水晶报表的数据显示有关问题

热度:1537   发布时间:2013-02-25 00:00:00.0
水晶报表的数据显示问题
请问,可以在显示水晶报表的页面的后台加入查询语句,以此来控制水晶报表显示的数据吗?

如果不行,那怎么才能实现以下功能:
数据库有多张表,怎么选择性的在水晶报表上显示一张表。

谢谢各位!!

------解决方案--------------------------------------------------------
兴建存储过程, 报表直接拉存储过程进来就行了。

报表空白处 右键 --数据库--数据库专家 将你的存储过程添加进来。

后台代码示例 cs:

ReportDocument myRpt = new ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
bind();
}
protected void Page_UnLoad(object sender, EventArgs e)
{
myRpt.Dispose();
}
protected void bind()
{
string period = txt_period.Text.Trim();
int equipment_type = int.Parse(ddl_type.SelectedValue);
string use_gx = txt_gx.Text.Trim();
string equipment_code = txt_equipmentcode.Text.Trim();
string equipment_code2 = txt_equipmentcode2.Text.Trim();

string path = Server.MapPath("../RptSources/DiscountReportByMonth.rpt");

myRpt.Load(path); 

Report report = new Report();
myRpt.SetDataSource(report.Get_DiscountReportByMonth(period, equipment_type, use_gx, equipment_code, equipment_code2,1));
CrystalReportViewer1.ReportSource = myRpt;
}
------解决方案--------------------------------------------------------
探讨

只有一个报表,不过这个报表连接的数据表有多行记录,我想通过传过来的值判断显示数据表哪一行的值。

我设计的报表,一页只显示数据表中一行的数据。
  相关解决方案