错误是:找不到类型或命名空间名称“CrystalReport1”(是否缺少 using 指令或程序集引用?)看看你是否有水晶报表的命名空间了? 加上这个没有? using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; using CrystalDecisions.Web;
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 CrystalDecisions.CrystalReports.Engine; using Citybase.Util;namespace Citybase.StatReports { /// <summary> /// Summary description for ReportsLinking. /// </summary> public class ReportsLinking : System.Web.UI.Page { protected System.Web.UI.WebControls.Label Label1; protected System.Web.UI.WebControls.LinkButton LinkButton1; protected System.Web.UI.WebControls.LinkButton LinkButton2; protected System.Web.UI.WebControls.LinkButton OccupantShortList_LinkButton; ReportDocument oRd;
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here Tool.setPageNoCache(this); } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click); this.LinkButton2.Click += new System.EventHandler(this.LinkButton2_Click); this.OccupantShortList_LinkButton.Click += new System.EventHandler(this.OccupantShortList_LinkButton_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion public void displayReport_for1Table(string sql,string strTableName,string strRptName) { SqlConn.ConnTool ct = new SqlConn.ConnTool(); ct.TableName ="aaa"; System.Data.DataSet dtst = ct.GetBatchRecords(sql); if(dtst.Tables[0].Rows.Count ==0 ) { Response.Write("<script language='javascript'>" ); Response.Write("alert('The data of the period is null ,please try again later!');"); Response.Write("</script>") ; Response.End() ; }
它不是CrystalReport
加上这个没有?
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
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 CrystalDecisions.CrystalReports.Engine;
using Citybase.Util;namespace Citybase.StatReports
{
/// <summary>
/// Summary description for ReportsLinking.
/// </summary>
public class ReportsLinking : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.LinkButton LinkButton1;
protected System.Web.UI.WebControls.LinkButton LinkButton2;
protected System.Web.UI.WebControls.LinkButton OccupantShortList_LinkButton;
ReportDocument oRd;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Tool.setPageNoCache(this);
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.LinkButton2.Click += new System.EventHandler(this.LinkButton2_Click);
this.OccupantShortList_LinkButton.Click += new System.EventHandler(this.OccupantShortList_LinkButton_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
public void displayReport_for1Table(string sql,string strTableName,string strRptName)
{
SqlConn.ConnTool ct = new SqlConn.ConnTool();
ct.TableName ="aaa"; System.Data.DataSet dtst = ct.GetBatchRecords(sql); if(dtst.Tables[0].Rows.Count ==0 )
{
Response.Write("<script language='javascript'>" );
Response.Write("alert('The data of the period is null ,please try again later!');");
Response.Write("</script>") ;
Response.End() ;
}
dtst.Tables[0].TableName =strTableName; this.oRd = new ReportDocument();
string rptFile = Request.MapPath("/Citybase/StatReports/Reports/" + strRptName + "");
this.oRd.Load(rptFile);
this.oRd.SetDataSource(dtst);
//oRd.DataDefinition.FormulaFields[0] = "{See_Date} = '2003/01/01'";
this.oRd.Refresh(); Tool.showReports(oRd,this,this.Context);
} public void displayReport_for2Table(string sql,string strTableName1,string strTableName2,string strRptName)
{
SqlConn.ConnTool ct = new SqlConn.ConnTool();
ct.TableName ="aaa"; System.Data.DataSet dtst = ct.GetBatchRecords(sql); if(dtst.Tables[0].Rows.Count ==0 || dtst.Tables[1].Rows.Count ==0 )
{
Response.Write("<script language='javascript'>" );
Response.Write("alert('The data of the period is null ,please try again later!');");
Response.Write("</script>") ;
Response.End() ;
}
dtst.Tables[0].TableName =strTableName1;
dtst.Tables[1].TableName =strTableName2; this.oRd = new ReportDocument();
string rptFile = Request.MapPath("/Citybase/StatReports/Reports/" + strRptName + "");
this.oRd.Load(rptFile);
this.oRd.SetDataSource(dtst);
this.oRd.Refresh(); Tool.showReports(oRd,this,this.Context);
}
private void LinkButton1_Click(object sender, System.EventArgs e)
{
string sql = "exec cb_Bank ";
string strTableName = "BankDetails";
string strRptName ="crptBankforDetails.rpt";
displayReport_for1Table(sql,strTableName,strRptName); } private void LinkButton2_Click(object sender, System.EventArgs e)
{
Response.Redirect("BuildingNameList.aspx");
} private void OccupantShortList_LinkButton_Click(object sender, System.EventArgs e)
{
string sql = "exec cb_stat_OccupantShortList "; string strTableName1 = "OccupantShortList";
string strTableName2 = "PremisesInformation";
string strRptName ="crptOccupantShortList.rpt";
displayReport_for2Table(sql,strTableName1,strTableName2,strRptName);
}
}
}