水晶报表“加载报表失败”

时间:2020-11-03 06:48:29

标签: c# windows crystal-reports

我的问题似乎是一个重复的问题,但这确实给我带来了困难。 我已经在C#版本16.7.6中开发了一个应用程序,我的CR报告是版本11。 问题是我的应用程序在计算机(也是开发计算机)中运行得像黄油一样,它也打开了CR,但是在其他任何计算机上,我的程序在加载CR时都抛出错误“加载报告失败”。下面是我的代码供参考:

private void LoadReport()
{
    ReportDocument cryrpt = new ReportDocument();
    try
    {
        TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
        TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
        ConnectionInfo crConnectionInfo = new ConnectionInfo();
        Tables CrTables;

        crConnectionInfo.ServerName = "*****";
        crConnectionInfo.DatabaseName = "*****";
        crConnectionInfo.UserID = "*****";
        crConnectionInfo.Password = "*****";

        MessageBox.Show(Application.StartupPath + @"\Prescription.rpt ");
        cryrpt.Load(Application.StartupPath + @"\Prescription.rpt");

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

        ParameterFieldDefinitions pfds;
        ParameterFieldDefinition pfd;
        ParameterValues pv = new ParameterValues();
        ParameterDiscreteValue pdv = new ParameterDiscreteValue
        {
            Value = Form1.PrescriptionNumberForReport    //captures the parameter value
        };
        pfds = cryrpt.DataDefinition.ParameterFields;
        pfd = pfds["FROMPRESNO"];
        pv = pfd.CurrentValues;
        pv.Clear();
        pv.Add(pdv);
        pfd.ApplyCurrentValues(pv);

        crystalReportViewer1.ReportSource = cryrpt;
        crystalReportViewer1.Refresh();
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error Encountered: " + ex.Message, "Search Prescription", MessageBoxButtons.OK, MessageBoxIcon.Error);
        if (cryrpt != null)
        {
            cryrpt.Close();
        }
    }
}

我将很高兴收到任何有关上述问题的建议或答复。

这是详细的错误:

error image

0 个答案:

没有答案
相关问题