Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ReportDocument rdoc = new ReportDocument();

        rdoc.Load(Server.MapPath("~/CrystalReport.rpt"));
        DataSetNotice dsn = this.GetData("Select class,year,subject,date,message from Message");

        rdoc.SetDataSource(dsn);
        CrystalReportViewer1.ReportSource = rdoc;
        CrystalReportViewer1.RefreshReport();
    }
Esempio n. 2
0
    private DataSetNotice GetData(string query)
    {
        string        cs  = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
        SqlConnection con = new SqlConnection(cs);

        con.Open();
        SqlCommand     cmd = new SqlCommand(query);
        SqlDataAdapter da  = new SqlDataAdapter(query, con);
        DataSetNotice  dsn = new DataSetNotice();

        da.Fill(dsn, "Message");
        return(dsn);
    }