[英]crystal report is not showing any data
我是水晶报告的新手。 但是我已经使用Google和asp.net论坛的帮助设计了一份水晶报告。 但是经过全部编码后,我无法在运行Visual Studio 2010后查看水晶报表。开发环境(Windows-7 32位,Visual Studio 2010,Crystal报表V.13)。 我的aspx如下所示:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ReportSapco.aspx.cs" Inherits="ReportSapco" %> <%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <link href="8LcKSBVeHKaZoXGjmWViuQ==/Site.css" rel="stylesheet" type="text/css" /> </head> <body style="background-color:#E6E6FA;"> <form id="form1" runat="server"> <CR:CrystalReportSource ID="CrystalReportSource1" runat="server"> <Report FileName="CertsReportSapco.rpt"> </Report> </CR:CrystalReportSource> <div> <CR:CrystalReportViewer ID="ReportViewer" runat="server" GroupTreeImagesFolderUrl="" Height="1269px" ToolbarImagesFolderUrl="" ToolPanelWidth="120px" Width="100%" EnableDatabaseLogonPrompt="False" EnableParameterPrompt="False" HasCrystalLogo="false" hasToggleGroupTreeButton="false" BestFitPage="false" ToolPanelView="None" BorderColor="#006699" BorderStyle="Solid" BorderWidth="2px" HasToggleParameterPanelButton="False" ReuseParameterValuesOnRefresh="True" HasSearchButton="False" onload="ReportViewer_Load" ReportSourceID="CrystalReportSource1" onunload="ReportViewer_Unload" /> </div> </form> </body> </html>
我的aspx.cs如下所示:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Globalization;
using CrystalDecisions.Web;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;
public partial class ReportSapco : System.Web.UI.Page
{
public static readonly string _ConStr = ConfigurationManager.ConnectionStrings["CStr"].ToString();
public static void CheckDB()
{
using (var _con = new SqlConnection(_ConStr))
{
if (_con.State == ConnectionState.Open)
{
_con.Close();
}
}
}
private DSCertsSapco GetData(string query)
{
SqlCommand cmd = new SqlCommand(query);
using (SqlConnection con = new SqlConnection(_ConStr))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DSCertsSapco dsCustomers = new DSCertsSapco())
{
sda.Fill(dsCustomers, "TB_NewSapcoCerts");
return dsCustomers;
}
}
}
}
protected void HomeBtn_Click(object sender, EventArgs e)
{
Response.Redirect("~/Default.aspx");
}
protected void BtnShowInfo_Click(object sender, EventArgs e)
{
string DateFrom = String.Format("{0}/{1}/01", GetCurYear(), DDownMonth.Text);
string DateTo = String.Format("{0}/{1}/31", GetCurYear(), DDownMonth.Text);
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("CertsReportSapco.rpt"));
DSCertsSapco dscerts = GetData("SELECT SuppCode,(SELECT SP_Name FROM TB_SupplierInfo WHERE (SP_Code=TB_NewSapcoCerts.SuppCode)) AS SuppName,PartNo,SerialNo,Code,PostedNo,(SELECT St_Name + ' ' + St_Family AS Expr1 FROM TB_StaffsInfo WHERE(St_PersCode=TB_NewSapcoCerts.SerialExporter)) AS SerialExporter,SerialIssuedDate,ID,SerialExporter as Perscode FROM TB_NewSapcoCerts where SerialExporter=N'" + int.Parse(Session["PersCode"].ToString()) + "' and suppcode='" + DDownSupp.Text + "' and SerialIssuedDate between '" + DateFrom + "' and '" + DateTo + "' and SerialStat<>6 order by SerialIssuedDate");
if (dscerts.Tables[0].Rows.Count > 0)
{
rpt.SetDataSource(dscerts);
rpt.SetParameterValue("Karfarma", "ساپکو");
rpt.SetParameterValue("Mah", DDownMonth.Text);
rpt.SetParameterValue("Personeli", Session["PersCode"].ToString());
rpt.SetParameterValue("PersName", Session["PersName"].ToString());
ReportViewer.ReportSource = rpt;
ReportViewer.DataBind();
}
else
{
ReportDocument rpt2 = new ReportDocument();
rpt2.Load(Server.MapPath("CertsReportSapco.rpt"));
rpt2.SetDataSource("");
rpt2.SetParameterValue("Karfarma", "");
rpt2.SetParameterValue("Mah", "");
rpt2.SetParameterValue("Personeli", "");
rpt2.SetParameterValue("PersName", "");
ReportViewer.ReportSource = rpt2;
}
}
protected void SapcoPrint_Click(object sender, EventArgs e)
{
Response.Redirect("~/ReportSaze.aspx");
}
protected void EpcoPrint_Click(object sender, EventArgs e)
{
Response.Redirect("~/ReportEpco.aspx");
}
protected void ReportViewer_Load(object sender, EventArgs e)
{
string DateFrom = String.Format("{0}/{1}/01", GetCurYear(), DDownMonth.Text);
string DateTo = String.Format("{0}/{1}/31", GetCurYear(), DDownMonth.Text);
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("~/CertsReportSapco.rpt"));
DSCertsSapco dscerts = GetData("SELECT SuppCode,(SELECT SP_Name FROM TB_SupplierInfo WHERE (SP_Code=TB_NewSapcoCerts.SuppCode)) AS SuppName,PartNo,SerialNo,Code,PostedNo,(SELECT St_Name + ' ' + St_Family AS Expr1 FROM TB_StaffsInfo WHERE(St_PersCode=TB_NewSapcoCerts.SerialExporter)) AS SerialExporter,SerialIssuedDate,ID,SerialExporter as Perscode FROM TB_NewSapcoCerts where SerialExporter=N'" + int.Parse(Session["PersCode"].ToString()) + "' and suppcode='" + DDownSupp.Text + "' and SerialIssuedDate between '" + DateFrom + "' and '" + DateTo + "' and SerialStat<>6 order by SerialIssuedDate");
if (dscerts.Tables[0].Rows.Count > 0)
{
rpt.SetDataSource(dscerts);
rpt.SetParameterValue("Karfarma", "ساپکو");
rpt.SetParameterValue("Mah", DDownMonth.Text);
rpt.SetParameterValue("Personeli", Session["PersCode"].ToString());
rpt.SetParameterValue("PersName", Session["PersName"].ToString());
ReportViewer.ReportSource = rpt;
}
else
{
ReportDocument rpt2 = new ReportDocument();
rpt2.Load(Server.MapPath("CertsReportSapco.rpt"));
rpt2.SetDataSource("");
rpt2.SetParameterValue("Karfarma", "");
rpt2.SetParameterValue("Mah", "");
rpt2.SetParameterValue("Personeli", "");
rpt2.SetParameterValue("PersName", "");
ReportViewer.ReportSource = rpt2;
}
}
protected void ReportViewer_Unload(object sender, EventArgs e)
{
if (ReportViewer != null)
{
ReportViewer.ReportSource = null;
ReportViewer.Dispose();
}
}
}
我调试了代码,发现出现以下错误:
HasRecords =禁用功能评估,因为先前的功能评估超时。 您必须继续执行才能重新启用功能评估水晶报表
HasDocuments之后的ReportDocument的所有属性出现此错误。
我在Google上搜索,发现某些东西陷入无限循环,或者应该删除所有断点以解决此错误。
但是据我观察,上述代码没有陷入无限循环,我删除了所有断点,但没有运气。
谁能帮我解决这个错误,我在运行代码后看不到水晶报表。
我正在获取空白页,并收到针对ReportDocument的错误。
我在注册表中设置“ PrintJobLimit” PROPERTY = 250,并在IIS中的“应用程序池”上启用32-Applications = True
挂起和此错误消息的原因可能是相同的:有些事情需要花费很多时间才能计算出来。 无论是在代码中还是在调试器中。
看来,当您尝试观察某些必须保证线程安全的变量时,可能会发生这种错误,但是有时此框架实现并不完美。
在这种情况下,“ HasRecords”没有出现在代码中,因此我认为是引起问题的监视窗口。
为避免此问题:在单步执行将变量绑定到Windows或其他控件的代码时,不要显示局部变量或“自动”变量。 仅在确定所有变量都可以安全查看时,才应查看此类内容。 并请注意,错误不一定会出现在不安全的变量上。 在危险代码中操作时,请对安全(即非控制)变量使用“立即”窗口。
1.第一步
解决方案是以这种方式在IIS上工作:
aspnet_client
文件夹从c:\\inetpub\\wwwroot
文件夹复制到新的网站根文件夹。 或(第一个比较容易,第二个更易于维护)
aspnet_client
的虚拟目录,该目录指向 c:\\inetpub\\wwwroot\\aspnet_client
2.第二步
将其复制到您的web.config
1。
<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>
2。
<businessObjects> <crystalReports> <rptBuildProvider> <add embedRptInResource="true" /> </rptBuildProvider> <crystalReportViewer> <add key="ResourceUri" value="/crystalreportviewers13" /> </crystalReportViewer> </crystalReports> </businessObjects>
3.第三步
将此引用添加到母版页或呈现报告的页面中的Crystal Report javascript中:
<script src='<%=ResolveUrl("~/crystalreportviewers13/js/crviewer/crv.js")%>'type="text/javascript"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.