我正在尝试在ASP.net
和C#
中开发一个简单的水晶报告。我正在使用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
。虽然没有错误,但可能出现什么问题?
答案 0 :(得分:0)
以下是解决问题的步骤
为Visual Studio 2010下载和安装Crystal Reports 13的运行时。(如果您之前已经执行此操作并且应用程序在本地工作,则可能需要跳过此步骤。)
安装运行时。 Crystal Reports将在本地计算机的位置安装所需的支持文件: C:\的Inetpub \ wwwroot的\ aspnet_client \ system_web \ 4_0_30319 \ crystalreportviewers13
将整个Crystal Report支持文件夹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
答案 1 :(得分:0)
添加上面的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>