博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

水晶报表开发

Posted on 2010-09-13 23:15  moss_tan_jun  阅读(250)  评论(0编辑  收藏  举报

 

  

  private static string Conn = ConfigurationManager.AppSettings["Str_Conn_14"].ToString();
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!Page.IsPostBack)
        //{
        //    this.Report();
        //}
    }

    public void Report()
    {
        ReportDocument RpDoc = new ReportDocument();
        string path = Server.MapPath("CrystalReport12.rpt");
        RpDoc.Load(path);

        SqlConnection SqlConn = new SqlConnection(Conn);
        SqlDataAdapter dpt = new SqlDataAdapter(" select * from dbo.tb_19", SqlConn);
        DataSet ds = new DataSet();

        dpt.Fill(ds);

        RpDoc.SetDataSource(ds);
        this.CrystalReportViewer1.ReportSource = RpDoc;
        this.CrystalReportViewer1.DataBind();
       

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        this.Report();
    }