如何获取水晶报表以将报表加载到客户端计算机上

时间:2020-01-04 08:21:29

标签: c# crystal-reports

我为一个家庭成员创建了一个系统,该系统仅用于一间小商店。因此,既然程序已经完成,我试图在他的PC上运行它,但是我一直收到负载报告错误。

-我做了一些调试,发现我知道程序要执行.load时会发生错误

这是我的报告代码

    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using Taksidermie.Classes;

    namespace Taksidermie
    {
public partial class Form3 : Form
{
    int FaktuurNo;
    public Form3(int _faktuurno)
    {
        InitializeComponent();
        FaktuurNo = _faktuurno;

        ReportDocument cryRpt = new ReportDocument();


        TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
        TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
        ConnectionInfo crConnectionInfo = new ConnectionInfo();
        Tables CrTables;

        string path = "C:\\Reports\\FaktuurPrintOut.rpt";


        cryRpt.Load(path);


        cryRpt.SetParameterValue("FId", FaktuurNo.ToString());

        crConnectionInfo.ServerName = database.server;
        crConnectionInfo.DatabaseName = database.dbName;
        crConnectionInfo.UserID = database.username;
        crConnectionInfo.Password = database.password;

        CrTables = cryRpt.Database.Tables;
        foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
        {
            crtableLogoninfo = CrTable.LogOnInfo;
            crtableLogoninfo.ConnectionInfo = crConnectionInfo;
            CrTable.ApplyLogOnInfo(crtableLogoninfo);
        }

        crystalReportViewer1.ReportSource = cryRpt;
        crystalReportViewer1.Refresh();
    }

    private void CrystalReportViewer1_Load(object sender, EventArgs e)
    {

    }

    private void CrystalReportViewer1_Load_1(object sender, EventArgs e)
    {

    }

    private void Form3_Load(object sender, EventArgs e)
    {

    }
}

}

这是错误消息

**************异常文本************** CrystalDecisions.Shared.CrystalReportsException:加载报告失败。 --->

System.Runtime.InteropServices.COMException:该文档尚未打开。 在CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.get_ReportAppServer() 在CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.get_ReportAppServer() 在CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() ---内部异常堆栈跟踪的结尾--- 在CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() 在CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String 文件名,OpenReportMethod openMethod,Int16 parentJob) 在CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String 文档名称) 在D:\ Program的Taksidermie.Form3..ctor(Int32 _faktuurno)中
文件\ Taksidermie \ Taksidermie \ Form3.cs:第33行 在Taksidermie.frmMainScreen.InvoiceToolStripMenuItem_Click(Object 发送者,EventArgs e)在
D:\ Program
文件\ Taksidermie \ Taksidermie \ Form1.cs:第345行 在System.Windows.Forms.ToolStripItem.RaiseEvent(Object key,EventArgs e) 在System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e) 在System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) 在System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) 在System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) 在System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea) 在System.Windows.Forms.Control.WmMouseUp上(消息和m,MouseButtons按钮,Int32单击) 在System.Windows.Forms.Control.WndProc(Message&m) 在System.Windows.Forms.ToolStrip.WndProc(Message&m) 在System.Windows.Forms.ToolStripDropDown.WndProc(Message&m) 在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)

我一直在寻找解决方案,但我找不到任何

我尝试过的是确保调试设置为64位而不是任何CPU 我更改了路径,以确保将其转到报告的正确文件夹,并为所有人提供了访问文件的权限

还有我要说的解决方案之一,该程序无法访问我的Temp文件夹。因此,我也可以访问该文件,但仍然一无所获。但是每次我在计算机上进行测试时,它都会运行,而我在其上进行测试的其他每台计算机都会给出负载报告错误

1 个答案:

答案 0 :(得分:0)

您是否已经在将要运行该软件的计算机上安装了Crystal Report Runtime Redistributable Package?

如果将调试设置为“任何CPU”,则安装将需要可再发行软件包的32位和64位版本。如果将调试设置为64位,则只需安装64位可再发行软件包。

还请记住,程序包的版本将由用于创建报表的Crystal Report Designer的版本确定。