Crsytall报告未在网页asp.net中显示

时间:2016-11-22 06:28:52

标签: asp.net crystal-reports

我想在asp.net中创建水晶报告,但是当我点击报告时,网页上没有显示。只显示一个空白网页,并显示按钮和文本字段,我通过该字段为报告提供参数。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Reporting;
using CrystalDecisions.CrystalReports.Engine;
using System.Data;

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

    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Regist"].ConnectionString);
    ReportDocument rdoc = new ReportDocument();
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {

        conn.Open();

        SqlCommand cmd = new SqlCommand("Regist", conn);

        cmd.CommandType = System.Data.CommandType.StoredProcedure;

//cmd.Parameters.AddWithValue("@AccountNumber",AccNumTB.Text);
        SqlDataAdapter da = new SqlDataAdapter(cmd);

        DataTable ds = new DataTable();
        da.Fill(ds);
        rdoc.Load(Server.MapPath("CrystalReport.rpt"));
        rdoc.SetDataSource(ds);
        rdoc.SetParameterValue("Frequency", AccNumTB.Text);
        CrystalReportViewer1.ReportSource = rdoc;
        CrystalReportViewer1.DataBind();

        conn.Close();
    }
}

0 个答案:

没有答案