如果您有任何意見,請留下您寶貴的意見以便告知
操作環境:Visual Studio.Net2003
操作系統:window Xp SP2
報表版本:Crystal Reports 10
放報表控件的頁面
1。ReportPage.ASPX
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using MedicineDetect.Class;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using MedicineDetect.Class;
//導入報表的命名空間
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace ReportDemo.Web.reportPage
{
/// <summary>
/// RollList 的摘要說明。
/// </summary>
public class ReportPage: System.Web.UI.Page
{
protected CrystalDecisions.Web.CrystalReportViewer rptDemo;
protected System.Web.UI.WebControls.Label lblStateDate;
protected System.Web.UI.WebControls.TextBox txtStartDate;
protected System.Web.UI.WebControls.Label lblEndDate;
protected System.Web.UI.WebControls.TextBox txtEndDate;
protected System.Web.UI.WebControls.Button btnSrch;
protected System.Web.UI.WebControls.Panel pnlSrch;
protected ReportDocument m_Doc = new ReportDocument();
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace ReportDemo.Web.reportPage
{
/// <summary>
/// RollList 的摘要說明。
/// </summary>
public class ReportPage: System.Web.UI.Page
{
protected CrystalDecisions.Web.CrystalReportViewer rptDemo;
protected System.Web.UI.WebControls.Label lblStateDate;
protected System.Web.UI.WebControls.TextBox txtStartDate;
protected System.Web.UI.WebControls.Label lblEndDate;
protected System.Web.UI.WebControls.TextBox txtEndDate;
protected System.Web.UI.WebControls.Button btnSrch;
protected System.Web.UI.WebControls.Panel pnlSrch;
protected ReportDocument m_Doc = new ReportDocument();
protected clsRpt.m_clsRpt.= new clsRpt(); //報表類
private void Page_Load(object sender, System.EventArgs e)
{
try
{
private void Page_Load(object sender, System.EventArgs e)
{
try
{
//加載報表
m_Doc.Load(Server.MapPath("..")+"/report/rptDemo.rpt");
m_Doc.Load(Server.MapPath("..")+"/report/rptDemo.rpt");
//調用綁定報表的方法
this.MultiSearch();
}
catch(Exception errExce)
{
errExce.Message.ToString();
}
finally
{
}
}
/// <summary>
/// 報表模糊查詢
/// </summary>
public string MultiSearch()
{
try
{
this.MultiSearch();
}
catch(Exception errExce)
{
errExce.Message.ToString();
}
finally
{
}
}
/// <summary>
/// 報表模糊查詢
/// </summary>
public string MultiSearch()
{
try
{
//調用類的方法
this.m_clsRpt.SelectAll();
this.m_clsRpt.SelectAll();
//設置報表的數據源(DataSet)
this.m_Doc.SetDataSource(m_clsRpt.MyDataSet);
this.rptDemo.ReportSource = m_Doc;
return " ";
}
catch(Exception errExce)
{
return errExce.Message.ToString();
}
finally
{
}
}
#region Web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調用是 ASP.NET Web 窗體設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
this.m_Doc.SetDataSource(m_clsRpt.MyDataSet);
this.rptDemo.ReportSource = m_Doc;
return " ";
}
catch(Exception errExce)
{
return errExce.Message.ToString();
}
finally
{
}
}
#region Web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調用是 ASP.NET Web 窗體設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
2。類文件: clsRpt.cs
/// <summary>
/// 查詢
/// </summary>
public string SelectAll()
{
try
{
MySqlCommand.CommandText = "sp_t_Report_SelectAll";
MySqlCommand.CommandType = CommandType.StoredProcedure;
MyDataAdapter = new SqlDataAdapter(MySqlCommand);
MyDataAdapter.Fill(MyDataSet, "t_Report");
return "";
}
catch(Exception errExce)
{
errExce.Message.ToString()
/// 查詢
/// </summary>
public string SelectAll()
{
try
{
MySqlCommand.CommandText = "sp_t_Report_SelectAll";
MySqlCommand.CommandType = CommandType.StoredProcedure;
MyDataAdapter = new SqlDataAdapter(MySqlCommand);
MyDataAdapter.Fill(MyDataSet, "t_Report");
return "";
}
catch(Exception errExce)
{
errExce.Message.ToString()
}
finally
{
}
}
finally
{
}
}
3。存儲過程 sp_t_Report_SelectAll
/*****************************************************************************
過 程 名 稱:sp_t_Report_SelectAll
功 能:
編 者:zhulei 時 間:2006-11-27
修 改 人: 修改時間:
******************************************************************************/
CREATE PROCEDURE [dbo].[sp_t_Report_SelectAll]
AS
BEGIN
SELECT *
FROM t_Report
END
GO
過 程 名 稱:sp_t_Report_SelectAll
功 能:
編 者:zhulei 時 間:2006-11-27
修 改 人: 修改時間:
******************************************************************************/
CREATE PROCEDURE [dbo].[sp_t_Report_SelectAll]
AS
BEGIN
SELECT *
FROM t_Report
END
GO
4。設置報表:
設置報表在這就不做具體的說明了,因爲沒什麼,只要創建一個DataSet,將表直接拖在DataSet上就可以了,然後就在報表上拖字段,畫畫樣式,就可以了.