我的sqlhelper:
   public DataSet ExcuteDataSet(string sqlname, CommandType type, params SqlParameter[] param)
        {
            try
            {
                con = Sqlconn.CreateSqlConnection();
                sda = new SqlDataAdapter(sqlname, con);
                sda.SelectCommand.CommandType = type;
                foreach (SqlParameter p in param)
                {
                    sda.SelectCommand.Parameters.Add(p);
                }
                ds = new DataSet();
                sda.Fill(ds);
                return ds;
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                con.Dispose();
            }
        }我的dal:
    public DataSet SaleCountByMonth()
       { 
       return helper.ExcuteDataSet(SQL_SALE_COUNT_BY_MONTH,CommandType.Text);
       }
我的bll:
   public DataSet SaleCountByMonth()
       {
           return reportdal.SaleCountByMonth();
       }
我的pageload:
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataSet ds = crbll.SaleCountByMonth();
                SqlDataAdapter sda;
                sda.Fill(ds);
                CRMDataSet cds;
                sda.Fill(cds);
                
                CrystalReportSource1.ReportDocument.Load(Server.MapPath("SaleCountByMonth.rpt"));
                CrystalReportSource1.DataBind();
                //先绑定后加载
                CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables[0].DefaultView);
                CrystalReportViewer1.ReportSource = CrystalReportSource1;
                CrystalReportViewer1.DataBind();
            }
        }
Justin<[email protected]>  14:58:36
我的sqlhelper:
   public DataSet ExcuteDataSet(string sqlname, CommandType type, params SqlParameter[] param)
        {
            try
            {
                con = Sqlconn.CreateSqlConnection();
                sda = new SqlDataAdapter(sqlname, con);
                sda.SelectCommand.CommandType = type;
                foreach (SqlParameter p in param)
                {
                    sda.SelectCommand.Parameters.Add(p);
                }
                ds = new DataSet();
                sda.Fill(ds);
                return ds;
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                con.Dispose();
            }
        }我的dal:
    public DataSet SaleCountByMonth()
       { 
       return helper.ExcuteDataSet(SQL_SALE_COUNT_BY_MONTH,CommandType.Text);
       }
我的bll:
   public DataSet SaleCountByMonth()
       {
           return reportdal.SaleCountByMonth();
       }
我的pageload:
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataSet ds = crbll.SaleCountByMonth();
                SqlDataAdapter sda;
                sda.Fill(ds);
                CRMDataSet cds;//自己创建的数据源(多表)
                sda.Fill(cds);
//这一部分不会写
                
                CrystalReportSource1.ReportDocument.Load(Server.MapPath("SaleCountByMonth.rpt"));
                CrystalReportSource1.DataBind();
                //先绑定后加载
                CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables[0].DefaultView);
                CrystalReportViewer1.ReportSource = CrystalReportSource1;
                CrystalReportViewer1.DataBind();
            }
        }

解决方案 »

  1.   

    protected void Page_Load(object sender, EventArgs e)
      {
      DataSet ds = crbll.SaleCountByMonth();
      CrystalReportSource1.ReportDocument.Load(Server.MapPath("SaleCountByMonth.rpt"));
      CrystalReportSource1.DataBind();
      //先绑定后加载
      CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables[0].DefaultView);
      CrystalReportViewer1.ReportSource = CrystalReportSource1;
      CrystalReportViewer1.DataBind();
      }
      

  2.   

    分层挺有意思的,SaleCountByMonth()没有参数,到DAL层居然可以调用带两参数的方法
      

  3.   

    参考资料:http://5-5.me/newsinfo/436.html
      

  4.   

    我就是想用到 xsd ~~~所以才问。dataset已经实现了~~ 但是打开速度相当的慢 尝试了别人用xsd的速度特别快~