由于刚开始使用水晶报表遇到如下问题不知道如何解决,希望能得到高手指点。开发环境是vs2008+sql2005
在做webform的水晶报表时,遇到了如下问题:
1、页面中初始水晶报表的时候显示正常。如下图2、点击 水晶报表中的 打印 按钮后就出现了 加载报表失败 的错误。以及一个 打印选项 的页面,如下图所示。3、点击 打印页面 的确定按钮后就报出了下图中的错误。
http://photo.renren.com/photo/264871061/photo-4024184388?curpage=0&t=
以下是本人的代码:using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data.SqlClient;
public partial class CustomsMessage_CustomsMainCR : System.Web.UI.Page
{
private ReportDocument myReport = new ReportDocument(); protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["CustomsBGID"] != null)
{
ViewState.Add("CustomsBGIDSession", Request.QueryString["CustomsBGID"]);
Response.Expires = -1;
ConfigureCrystalReports(ViewState["CustomsBGIDSession"].ToString());
}
else
{
Response.Expires = -1;
ConfigureCrystalReports("6");
}
} }
/// <summary>
/// 初始化报表
/// </summary>
private void ConfigureCrystalReports(string CustomsBGID)
{
string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
SqlConnection cn = new SqlConnection(connectionString);
SqlDataAdapter da = new SqlDataAdapter(); //获取记录集,注意,最终获取的记录集需要与xsd的结构一致!
//即使是子报表,也是同样的方法,因为这还是那个 Dataset! DataSet ds = new DataSet();
Transport.BLL.PublicBll pbBll = new Transport.BLL.PublicBll(); da = new SqlDataAdapter(" select [CustomsBGID],[ConsignmentId],[ExportOrImport],[OceanFly],[BillID],[CustomsId],[PreInputId],[IEPort],[manual_no],[IEDate],[DeclareDate],[TradeCoCode],[TradeCoName],[ShpperCode],[DeclareName],[TransMode],[TransDeName],[BillNo],[TradeMode],[TaxFreeMode],[TaxRate],[ForexMode],[LicenseNo],[TradeCountry],[LoadPort],[DestPort],[ShipperDistrictCode],[ShpperName],[ConfirmNo],[BussMode],[FeeRate],[FeeCurrency],[InsureRate],[InsureCurrency],[InsureMark],[OtherRate],[OtherCurrency],[OtherMark],[ContractNo],[Quantity],[PackageType],[GrossWT],[NetWT],[CTNNum],[AddBill],[UseWay],[ProductFactory],[Marks],[FeeMark],[DeclareCode],[InputMan],[Comment],[CoProperty],[PayTaxesMode],[TaxFeeStatus],[ManualRePortNo],[VerificationFormCount],[ManualsCount],[TaxRebateCount],[RemittanceCount],[BlueInvoiceCount],[InvoiceMoney],[InvoiceMoneyCurrency],[CustomsInfo],[ETCount],[QPCount],[TransiCount],[ScalpingDate],[ChargeBackDate],[LawReviewCount],[SecBillCount] from [B_Customs] where CustomsBGID='" + CustomsBGID + "' ", cn);
//注意表名,需要与xsd中的一致!此处尽量不要忽略。
da.Fill(ds, "B_Customs"); //1.商品明细
da = new SqlDataAdapter(" select [CustomsItemsID],[CustomsBGID],[ItemID],[HSCode],[HSFullName],[HSNameAddition],[HSQuantiry],[HSUnit],[HSUnitName],[OriginCountry],[Destination],[CountryName],[HSUnitPrice],[HSTotalPrice],[Currency],[PayTaxMode],[PayTaxModeName] from [B_CustomsHSItems] where CustomsBGID='" + CustomsBGID + "'", cn);
da.Fill(ds, "B_CustomsHSItems"); //以上为数据部分,与报表无关
//-----------------------------------------------------------
//以下为报表部分 //使用报表对象加载报表
string reportPath = Server.MapPath("..\\CustomsMessage\\CustomsMainCR.rpt");
myReport.Load(reportPath); //绑定数据集,注意,一个报表用一个数据集。
myReport.SetDataSource(ds);
ReportViewer.ReportSource = myReport;
} }
在做webform的水晶报表时,遇到了如下问题:
1、页面中初始水晶报表的时候显示正常。如下图2、点击 水晶报表中的 打印 按钮后就出现了 加载报表失败 的错误。以及一个 打印选项 的页面,如下图所示。3、点击 打印页面 的确定按钮后就报出了下图中的错误。
http://photo.renren.com/photo/264871061/photo-4024184388?curpage=0&t=
以下是本人的代码:using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data.SqlClient;
public partial class CustomsMessage_CustomsMainCR : System.Web.UI.Page
{
private ReportDocument myReport = new ReportDocument(); protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["CustomsBGID"] != null)
{
ViewState.Add("CustomsBGIDSession", Request.QueryString["CustomsBGID"]);
Response.Expires = -1;
ConfigureCrystalReports(ViewState["CustomsBGIDSession"].ToString());
}
else
{
Response.Expires = -1;
ConfigureCrystalReports("6");
}
} }
/// <summary>
/// 初始化报表
/// </summary>
private void ConfigureCrystalReports(string CustomsBGID)
{
string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
SqlConnection cn = new SqlConnection(connectionString);
SqlDataAdapter da = new SqlDataAdapter(); //获取记录集,注意,最终获取的记录集需要与xsd的结构一致!
//即使是子报表,也是同样的方法,因为这还是那个 Dataset! DataSet ds = new DataSet();
Transport.BLL.PublicBll pbBll = new Transport.BLL.PublicBll(); da = new SqlDataAdapter(" select [CustomsBGID],[ConsignmentId],[ExportOrImport],[OceanFly],[BillID],[CustomsId],[PreInputId],[IEPort],[manual_no],[IEDate],[DeclareDate],[TradeCoCode],[TradeCoName],[ShpperCode],[DeclareName],[TransMode],[TransDeName],[BillNo],[TradeMode],[TaxFreeMode],[TaxRate],[ForexMode],[LicenseNo],[TradeCountry],[LoadPort],[DestPort],[ShipperDistrictCode],[ShpperName],[ConfirmNo],[BussMode],[FeeRate],[FeeCurrency],[InsureRate],[InsureCurrency],[InsureMark],[OtherRate],[OtherCurrency],[OtherMark],[ContractNo],[Quantity],[PackageType],[GrossWT],[NetWT],[CTNNum],[AddBill],[UseWay],[ProductFactory],[Marks],[FeeMark],[DeclareCode],[InputMan],[Comment],[CoProperty],[PayTaxesMode],[TaxFeeStatus],[ManualRePortNo],[VerificationFormCount],[ManualsCount],[TaxRebateCount],[RemittanceCount],[BlueInvoiceCount],[InvoiceMoney],[InvoiceMoneyCurrency],[CustomsInfo],[ETCount],[QPCount],[TransiCount],[ScalpingDate],[ChargeBackDate],[LawReviewCount],[SecBillCount] from [B_Customs] where CustomsBGID='" + CustomsBGID + "' ", cn);
//注意表名,需要与xsd中的一致!此处尽量不要忽略。
da.Fill(ds, "B_Customs"); //1.商品明细
da = new SqlDataAdapter(" select [CustomsItemsID],[CustomsBGID],[ItemID],[HSCode],[HSFullName],[HSNameAddition],[HSQuantiry],[HSUnit],[HSUnitName],[OriginCountry],[Destination],[CountryName],[HSUnitPrice],[HSTotalPrice],[Currency],[PayTaxMode],[PayTaxModeName] from [B_CustomsHSItems] where CustomsBGID='" + CustomsBGID + "'", cn);
da.Fill(ds, "B_CustomsHSItems"); //以上为数据部分,与报表无关
//-----------------------------------------------------------
//以下为报表部分 //使用报表对象加载报表
string reportPath = Server.MapPath("..\\CustomsMessage\\CustomsMainCR.rpt");
myReport.Load(reportPath); //绑定数据集,注意,一个报表用一个数据集。
myReport.SetDataSource(ds);
ReportViewer.ReportSource = myReport;
} }
解决方案 »
- 网页需要做一个淘宝旺旺
- 饼图高分求救,vml高手请进!
- 我想形成类似“井”字这种datagrid表外观。整个表的底色为白色不变,内部格线为黑色
- 上海寻asp.net开发人员,可兼职(需在上海)
- 怎样保持文本原有的空格换行显示?像csdn上的发帖子时,发表时有空格,或换行的地方显示的时候也有?
- 数据库内HTML的问题,大家请进!
- 我刚学做网站,只装了.net,我在看一些例子的时候会遇到一些javascript语句,我想看一些帮助,从哪去找?
- 网站ASP好像有问题,恳求高手帮忙
- 日期相加减问题,请求大家帮忙?
- 向大哥们学习学习
- dalalist获取控件
- window.showModalDialog 弹出窗口问题!
protected void btnOP_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this.UP1, this.GetType(), "SubmitOK", "window.open('CustomsMainCR.aspx?CustomsBGID=" + txtID.Text + "');", true);
}
#endregion
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="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
rel="stylesheet" type="text/css" />
<link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
rel="stylesheet" type="text/css" />
<link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
rel="stylesheet" type="text/css" />
<link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<CR:CrystalReportViewer ID="ReportViewer" runat="server" AutoDataBind="true" ReportSourceID="CrystalReportSource1"/>
<CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
<Report FileName="CrystalReport1.rpt">
</Report>
</CR:CrystalReportSource>
</div>
</form>
</body>
</html>
图二:http://photo.renren.com/photo/264871061/photo-4024184390?curpage=0&t=#4024184389
图三:http://photo.renren.com/photo/264871061/photo-4024184390?curpage=0&t=#4024184388