水晶报表----子报表

来源:互联网 发布:java博客园 编辑:程序博客网 时间:2024/06/09 20:10

     经过了一段时间对水晶报表的操作,我对其稍稍了解了一点点。

     这两天,一直在为数据量太大而烦恼,我有六张表,其中一张关联剩余的五张表。想要显示数据,结果,显示不出来,即使我已经在链接里面设置了左外连接。

     我知道这个是按照笛卡尔积相乘,所以数据会成倍的增加。所以,即使我改用直接连接数据库的方式也行不通。就是PULL模式。

     protected void Page_Unload(object sender, EventArgs e)
    {

        CrystalReportViewer1.Dispose();
        ReportDocument report = new ReportDocument();
        if (report != null)
        {
            report.Close();
            report.Dispose();
        }

    }

 

 

    /// <summary>
    /// 用一个水晶报表显示统计的结果
    /// </summary>
    private void ConfigureCrystalReports()
    {
         ConnectionInfo connectionInfo = new ConnectionInfo();
        connectionInfo.ServerName = "N2";
        connectionInfo.DatabaseName = "Ec";
        connectionInfo.UserID = "r";
        connectionInfo.Password = "";
        //connectionInfo.Type = ConnectionInfoType.SQL;
        //connectionInfo.IntegratedSecurity = false;
        ReportDocument report = new ReportDocument();
        string reportPath = Server.MapPath("S_warningwip.rpt");
        report.Load(reportPath);
        CrystalReportViewer1.ReportSource = report;
     
        ParameterFields parameterFields = CrystalReportViewer1.ParameterFieldInfo;
        SetDBLogonForReport(connectionInfo);
    }


    private void SetDBLogonForReport(ConnectionInfo connectionInfo)
    {
        TableLogOnInfos tableLogOnInfos = CrystalReportViewer1.LogOnInfo;
        foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
        {
            tableLogOnInfo.ConnectionInfo = connectionInfo;
        }
    }

 

 

    后来看了网上的一些关于子报表的文章,还有问了一些热于助人的网友,感谢中,慢慢的我对子报表的操作有了一定的了解,当然,如果不算深入。

      用了子报表,可以解决数据量大的问题,不过在使用的过程中,因为或多或少的不熟,会有些问题,亲爱的同志们,只要你坚持专研,一定可以得到你想要的结果。

 

     strsql = GETdatetime(this.TextBox1.Text.ToString().Trim()) + GETpanelid(this.TextBox2.Text.ToString().Trim()) + GETscrapreason(this.TextBox3.Text.ToString().Trim());
        SqlConnection cn = CommonClass.getConnection();
        cn.Open();
        DataSet ds = new DataSet();
        string sql;
        sql = "select ID,SIZE from B_Size where isdel=0";
        SqlDataAdapter da = new SqlDataAdapter(sql, cn);
        da.Fill(ds, "B_Size");

        sql = "select ID, ProType from B_ProductionType where ISDEL=0";
        da = new SqlDataAdapter(sql, cn);
        da.Fill(ds, "B_ProductionType");


        sql = "select ID, step from B_Step where ISDEL=0 order by orderid ";
        da = new SqlDataAdapter(sql, cn);
        da.Fill(ds, "B_Step");

        sql = "select ID, PanelType from B_PanelType where ISDEL=0";
        da = new SqlDataAdapter(sql, cn);
        da.Fill(ds, "B_PanelType");

        sql = "select ID,panelid,scrapdate,scrapreason,protypeid,paneltypeid,panelsizeid,scrapstepid,stnumber from n_p_ScrapInfo   where 0=0 " + strsql;
        da = new SqlDataAdapter(sql, cn);
        da.Fill(ds, "n_p_ScrapInfo");

 


        ReportDocument report = new ReportDocument();
        string reportPath = Server.MapPath("J_scrapinfo.rpt");
        report.Load(reportPath);
        report.SetDataSource(ds);
        CrystalReportViewer1.ReportSource = report;
        CrystalReportViewer1.DataBind();
        tag = "click";

特别的要感谢阿泰,因为他的视频教程给了我很多的启发。谢谢~~~~~~~

原创粉丝点击