我是水晶报道的新手。 但我已经使用谷歌和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 =功能评估已禁用,因为之前的功能 评估超时。您必须继续执行以重新启用功能 评估水晶报告
对于ReportDocument的HasRecords,我收到了所有属性的错误。
我用Google搜索并发现某些内容无限循环或应删除所有断点以解决此错误。
但是根据我的观察,上面提到的代码没有任何内容无限循环,我删除了所有的断点,但没有运气。
有没有人帮我解决这个错误我在运行代码后无法看到水晶报告。
我收到空白页并收到ReportDocument的错误。
我在registry = 250中设置“PrintJobLimit”PROPERTY并在IIS中启用应用程序池上的32应用程序= True
答案 0 :(得分:0)
挂起和此错误消息的原因可能是相同的:有些东西需要花费大量时间来计算。在代码和调试器中执行此操作时 看来这种错误只是在你试图观察一些必须是线程安全的变量时才会发生,但有时候这个框架实现并不完美...... 在这种情况下,“HasRecords”没有出现在代码中,因此我认为是观察窗口会导致问题。
要避免此问题:当单步执行变量绑定到窗口或其他控件的代码时,不会显示局部变量或“自动”变量。只有在确定您的变量可以安全查看时,才能查看这些内容。请注意,错误不一定出现在不安全的变量上。在危险代码中操作时,请使用安全(即非控制)变量的“立即”窗口。
答案 1 :(得分:0)
<强> 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。第三步
将此引用添加到您的母版页或渲染报告的页面中的水晶报告javascript:
<script src='<%=ResolveUrl("~/crystalreportviewers13/js/crviewer/crv.js")%>'type="text/javascript"></script>