【问题标题】:Why doesn't my CrystalReportViewer display Results?为什么我的 CrystalReportViewer 不显示结果?
【发布时间】:2015-06-22 17:28:31
【问题描述】:

我正在尝试在ASP.netC# 中开发一个简单的水晶报表。我正在使用CrystalReportViewer 加载我的报告。 这是 C# 代码:

protected void Page_Load(object sender, EventArgs e)
{
    SqlConnection con;
    string connString = null;
    connString = "Data Source=.;initial catalog=InvoiceSystem;user id=sa;password=rfm";
    con = new SqlConnection(connString);
    con.Open();

    string query = null;
    query = "Select * from tblInvoice";
    SqlDataAdapter da = new SqlDataAdapter(query, con);
    con.Close();
    DataSetInv ds = new DataSetInv();
    da.Fill(ds, "tblInvoice");
    ReportDocument rpt = new ReportDocument();
    rpt.Load(Server.MapPath("~/CrystalReportInv.rpt"));
    rpt.SetDataSource(ds);
    CrystalReportViewer1.ReportSource = rpt;
}

问题是我的,CrystalReportViewer 不是render 我在浏览器上的报告,它是blank page。虽然没有错误,但可能有什么问题?

【问题讨论】:

  • 你有没有把 aspnet_client 文件夹放到 IIS 根目录(C:\inetpub\wwwroot)

标签: asp.net c#-4.0 visual-studio-2012 crystal-reports webpage-rendering


【解决方案1】:

以下是解决问题的步骤

  1. 下载和安装 Crystal Reports 13 for Visual Studio 2010 的运行时。(如果您之前已经执行过此步骤并且您的应用程序在本地运行,则可能需要跳过此步骤)。

  2. 安装运行时后。 Crystal Reports 将在本地计算机的位置安装所需的支持文件: C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13

  3. 将整个 Crystal Report Support 文件夹 C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13 复制到您网站的 SITE_ROOT\aspnet_client\system_web\4_0_30319 文件夹中。

4) 如果您的网站根目录中没有 \aspnet_client\system_web\4_0_30319 文件夹。请手动创建它们,然后将 crystalreportviewers13 复制到其中。

参考这个Crystal Report is unable to find the required JavaScript (JS) files to render the report in browser

【讨论】:

    【解决方案2】:

    除了上面 Sain Pradeep 描述的步骤

    在您的 Web.Config 文件中添加以下内容(.Net 4.0 及更高版本)

    <configSections>
      <sectionGroup name="businessObjects">
        <sectionGroup name="crystalReports">
          <section name="rptBuildProvider" type="CrystalDecisions.Shared.RptBuildProviderHandler, CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, Custom=null" />
          <section name="crystalReportViewer" type="System.Configuration.NameValueSectionHandler" />
        </sectionGroup>
    
      </sectionGroup>
    </configSections>
    
    <businessObjects>
      <crystalReports>
        <rptBuildProvider>
          <add embedRptInResource="true" />
        </rptBuildProvider>
        <crystalReportViewer>
          <add key="ResourceUri" value="/crystalreportviewers13" />
        </crystalReportViewer>
      </crystalReports>
    </businessObjects>
    

    【讨论】:

    • 这是由 Visual Studio 自动添加到我的 Web.config 中的 :)
    • 网站项目自动将此添加到 web.config 文件中,但不在 Web 应用程序项目中
    猜你喜欢
    • 2021-12-17
    • 2021-12-21
    • 1970-01-01
    • 2019-06-04
    • 1970-01-01
    • 1970-01-01
    • 2018-04-25
    • 2016-01-02
    • 2016-03-02
    相关资源
    最近更新 更多