VS2008 制作水晶报表时候碰到的一…

VS2008 制作水晶报表时候碰到的一些问题

CS代码:

using System;

using System.Collections.Generic;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using CrystalDecisions.Shared;

using CrystalDecisions.CrystalReports.Engine;

using System.Data.SqlClient;

using System.Data;

using XDDataEntity;

 

 

namespace Web.dingdan

{

    public partial class BillPrint : System.Web.UI.Page

    {

        string BillID = "122,124,126,127,128,129";

        protected void Page_Load(object sender, EventArgs e)

        {

            BillID = Request["BillID"];

            if (!IsPostBack)

            {

                DataBind();

            }

        }

        protected void Button1_Click(object sender, EventArgs e)

        {

            DataBind();

        }

        public void DataBind()

        {

            if (BillID == null)

            {

                BillID = "0";

            }

            string ServerName, Database, Userid, Pass;

            //获取ServerName

            ServerName = System.Configuration.ConfigurationSettings.AppSettings["servername"];

            //获取DatabaseName

            Database = System.Configuration.ConfigurationSettings.AppSettings["database"];

            //获取UserId

            Userid = System.Configuration.ConfigurationSettings.AppSettings["userid"];

            //获取password

            Pass = System.Configuration.ConfigurationSettings.AppSettings["pass"];

            //设置logOnInfo参数

            ConnectionInfo logOnInfo = new ConnectionInfo();

            logOnInfo.ServerName = ServerName;

            logOnInfo.DatabaseName = Database;

            logOnInfo.UserID = Userid;

            logOnInfo.Password = Pass;

            //报表路径

            String path = Server.MapPath("Report" + DdlDYGS.SelectedIndex + ".rpt");

            CrystalReportSource1.ReportDocument.Load(path);

            //将数据库信息传递给报表

            SetDBLogonForReport(logOnInfo, CrystalReportSource1.ReportDocument);

            CrystalReportSource1.ReportDocument.SetParameterValue("ID", BillID);

            CrystalReportSource1.DataBind();

        }

        private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)

        {

            Tables tables = reportDocument.Database.Tables;

 

            foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)

            {

                TableLogOnInfo tableLogonInfo = table.LogOnInfo;

                tableLogonInfo.ConnectionInfo = connectionInfo;

                table.ApplyLogOnInfo(tableLogonInfo);

            }

        }

    }

 

Form界面代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BillPrint.aspx.cs" Inherits="Web.dingdan.BillPrint" %>

 

<%@ Register assembly="CrystalDecisions.Web, Version=10.5.3700.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 runat="server">

    <title></title>

    <style type="text/css">

        .style1

        {

            width: 60px;

        }

    </style>

</head>

<link href="../Style/css.css" rel="stylesheet" type="text/css" />

<body>

    <form id="form1" runat="server">

    <div>

   

        &nbsp;<table style="width:100%;">

            <tr>

                <td class="style1">

   

                    &nbsp;</td>

                <td>

   

        打印格式:&nbsp;

                    <asp:DropDownList ID="DdlDYGS" runat="server" Height="24px" Width="237px">

                        <asp:ListItem>地址标签</asp:ListItem>

                        <asp:ListItem>地址标签+条码</asp:ListItem>

                        <asp:ListItem>地址标签+回邮地址</asp:ListItem>

                        <asp:ListItem>地址标签+回邮地址+条码+报关单</asp:ListItem>

                    </asp:DropDownList>

&nbsp;

                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="打印"

                        Width="96px" />

                &nbsp;

                    <asp:Button ID="Button2" runat="server" Text="返回"

                        Width="96px" PostBackUrl="javascript:history.go(-1)" />

                </td>

                <td>

                    &nbsp;</td>

            </tr>

            <tr>

                <td class="style1">

                    &nbsp;</td>

                <td>

                    &nbsp;</td>

                <td>

                    &nbsp;</td>

            </tr>

            <tr>

                <td class="style1">

                    &nbsp;</td>

                <td>

                    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"

                        AutoDataBind="True" Height="50px"

                        Width="350px" ReportSourceID="CrystalReportSource1" />

                    <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">

                        <Report FileName="dingdan\Report0.rpt">

                        </Report>

                    </CR:CrystalReportSource>

                </td>

                <td>

                    &nbsp;</td>

            </tr>

        </table>

    </div>

    </form>

</body>

</html>

 

1.      发布的时候.报表文件不会自动发布.手动复制rpt文件到服务器bin文件夹下面

2.       在打开网站的时候.报错. 未能加载文件或程序集“CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304”或它的某一个依赖项

解决方法:

我是先找到了VS2008安装盘下面搜索 Report ,找到如下二个安装包.

CrystalReports2007.msi CrystalReports2007_x86_CHS.msi 复制到服务器中安装.

另外:看网上资料.好像是说直接使用我碰到的第三个解决办法就能解决.因为我是先碰到第一个问题.用我的方法处理的.所以后面的又让我给碰到了.呵呵....

3.       检索 COM 类工厂中 CLSID {5FF57840-5172-4482-9CA3-541C7878AE0F} 的组件时失败,原因是出现以下错误:

解决方法:

复制编译机器里面 找到下面路径,复制文件夹里面的CRRedist2008_x86.msi ,在服务器安装即可.

C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5

4.       水晶报表不显示工具栏图标

原因: 分析网页源码,找到代码如下

<table cellspacing=0 cellpadding=0><tr nowrap>
<td nowrap width=
8>&nbsp;</td><td nowrap width=22px><input type="image" name="CrystalReportViewer1$ctl02$ctl00" disabled="disabled" title="Export" src="/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer4/images/toolbar/export.gif" οnmοuseοver="this.src='/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer4/images/toolbar/export_over.gif'" οnmοuseοut="this.src='/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer4/images/toolbar/export.gif'" style="height:22px;width:22px;border-width:0px;" /></td>
<td nowrap width=
8>&nbsp;</td><td nowrap width=22px><input type="image" name="CrystalReportViewer1$ctl02$ctl01" disabled="disabled" title="Print" src="/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer4/images/toolbar/print.gif" οnmοuseοver="this.src='/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer4/images/toolbar/print_over.gif'" οnmοuseοut="this.src='/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer4/images/toolbar/print.gif'" style="height:22px;width:22px;border-width:0px;" /></td>
<td nowrap width=
8>&nbsp;</td><td nowrap width=22px><input type="image" name="CrystalReportViewer1$ctl02$ctl03" disabled="disabled" title="Show/Hide Group Tree" src="/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer4/images/toolbar/grouptree.gif" οnmοuseοver="this.src='/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer4/images/toolbar/grouptree_over.gif'" οnmοuseοut="this.src='/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer4/images/toolbar/grouptree.gif'" style="height:22px;width:22px;border-width:0px;" /></td>

 

解决方法:

复制服务器C:\Inetpub\wwwroot 下面aspnet_client文件夹到 当前安装程序bin下面. 为了简便.记得可是要aspnet_client文件整个复制过去. 或者.只复制C:\Inetpub\wwwroot\aspnet_client\system_web\2_0_50727\CrystalReportWebFormViewer4 下面的文件  bin 文件夹下面的路径要和这个一模一样.不然还是会显示不出来的.小红叉叉.呵呵….

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值