簡體   English   中英

水晶報表未顯示任何數據

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM