【问题标题】:Asp net C# Webpage RDLC Report not Showing DataAsp net C# 网页 RDLC 报告不显示数据
【发布时间】:2017-03-13 20:30:46
【问题描述】:

我是 C# 和 Asp.net 的新手,我正在尝试使用 Rdlc Report,但我无法在 Report 上打印数据

<body>
    <form id="form1" runat="server">
    <div>


        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" >
            <LocalReport ReportPath="Report.rdlc">

            </LocalReport>

        </rsweb:ReportViewer>

        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

         <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
    </div>

    </form>
</body>




 protected void Page_Load(object sender, EventArgs e)
{   
    if (!IsPostBack)
    {
        string before = Session["before"].ToString();
        string after = Session["after"].ToString();

        Label1.Text = before.ToString();
        Label2.Text = after.ToString();

        string src = "Data Source=.; Initial Catalog=mydbtry; Integrated Security=true;";
        SqlConnection con = new SqlConnection(src);
        try
        {
            con.Open();

            DateTime b = Convert.ToDateTime(before);
            DateTime a = Convert.ToDateTime(after);
            string query = "Select * from firstTable where id = 155";
             SqlCommand cmd = new SqlCommand(query);
            DataSet ds;
            using (con)
            {
                using (SqlDataAdapter da = new SqlDataAdapter())
                {
                    cmd.Connection = con;
                    da.SelectCommand = cmd;
                    ds = new DataSet();
                    da.Fill(ds);

                }
            }

            ReportViewer1.ProcessingMode = ProcessingMode.Local;
            ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
            ReportDataSource rds = new ReportDataSource("DataSet1", ds.Tables[0]);
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(rds);
            ReportViewer1.LocalReport.Refresh();                
        }


        catch (Exception ex)
        {


        }


    }

我现在面临的问题是,我的表是空的并且没有填充数据。 我正在使用 sql server 2012,并且我已经检查了连接是否正常。

执行后

数据集

报告.RDLC

任何帮助将不胜感激。

【问题讨论】:

    标签: c# asp.net report webpage rdlc


    【解决方案1】:

    尝试通过 ObjectDataSource 控件填充您的报告。自动运行,无需任何代码

    【讨论】:

    • 我自己已经解决了问题;我的 DataSet 没有检索到正确的表...还是谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-13
    • 2015-08-04
    • 1970-01-01
    • 1970-01-01
    • 2019-07-22
    • 1970-01-01
    相关资源
    最近更新 更多