有CrystalReport1类吗?是不是CrystalReport啊?没搞过,不清楚:(
学习ing

解决方案 »

  1.   

    按照看过的资料,这里的CrystalReport1就是CrystalReport1.rpt文件。
    它不是CrystalReport
      

  2.   

    错误是:找不到类型或命名空间名称“CrystalReport1”(是否缺少 using 指令或程序集引用?)看看你是否有水晶报表的命名空间了?
    加上这个没有?
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using CrystalDecisions.Web;
      

  3.   

    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() ;
    }

    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);
    }
    }
    }
      

  4.   

    对不起,我忘了交待一下,在我的系统中,*.aspx没有*.aspx.cs可调用(类似微软的asp.net forums的组织方法。)我用<script ></script>来调用C#代码。前面的using ...都必须用<%@import ..%>代替。再有kurt154兄的办法虽然可以,但用不上。