VS2005中的ReportViewer的使用

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;
using Microsoft.ApplicationBlocks.Data;

public partial class biao : System.Web.UI.Page
{

    public string thisConnectionString = ConfigurationManager.ConnectionStrings[ "testConnectionString"].ConnectionString;
            
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        SqlConnection conn = new SqlConnection(thisConnectionString);
        conn.Open();

        SqlCommand command = new SqlCommand("select * from ceshi", conn);

        SqlDataAdapter da = new SqlDataAdapter(command);

        DataSet ds = new DataSet();

        da.Fill(ds);

        //爲報表瀏覽器指定報表文件
        ReportViewer1.LocalReport.ReportEmbeddedResource = "report.Report1.rdlc";
        //顯示報表
        ReportViewer1.LocalReport.ReportPath = "Report1.rdlc";
        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1_ceshi", ds.Tables[0]));
        ReportViewer1.LocalReport.Refresh();
      //ReportViewer1.RefreshReport();

    }
  }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章