Java Crystal Report SDK报告和子报表-子报表参数给出错误错误代码:-2147217394错误代码名称:missingParameterValueError

时间:2019-06-20 19:06:06

标签: java sdk crystal-reports report crystal-reports-2010

我正在将Crystal Report与Java集成在一起,当我有一个没有子报表的报表时,便能够将报表导出为PDF。

但是,当我在子报表中包含一个参数时,即使在子报表中声明了参数值,也遇到了错误。

子报表参数:

reportClientDocument.getDataDefController().getParameterFieldController().setCurrentValue("TranslateLabels", "Pm-@PrintLanguage", new String("ENG"));

我不确定缺少什么,或者我是否必须以其他方式提供值。

请让我知道缺少了什么?或者,如果您可以附上示例,将不胜感激。

错误:

The program is giving error: Error code:-2147217394 Error code name:missingParameterValueError

Caused by: com.crystaldecisions.reports.common.MissingParameterValuesException: Some parameters are missing values

完整代码:

public static void printInvoice(int invoiceNum) throws Exception{
    Connection c = null;
    PreparedStatement ps;
    PreparedStatement pssub;
    ResultSet rs = null;
    ResultSet rssub = null;
    String subreportName = "TranslateLabels";
    String mainReportParamName = "PrintLanguage";
    String mainReportParamValue = "ENG";

    try {
        c = DBConnectionPools.getConn();
        StringBuffer sb = new StringBuffer();
        sb.append(" SELECT * FROM Invoice inv ");
        sb.append(" LEFT JOIN Language  la ON inv.PrintLang = la.PrintLang ");
        sb.append(" WHERE InvoiceNum = ?  ");
        ps = c.prepareStatement(sb.toString());
        ps.setInt(1, invoiceNum);
        rs = ps.executeQuery();

        //Main Report 
        ReportClientDocument reportClientDocument = new ReportClientDocument();
        reportClientDocument.open("H:Invoice.rpt",0);
        reportClientDocument.getDatabaseController().setDataSource(rs);
        reportClientDocument.getDataDefController().getParameterFieldController().setCurrentValue("", mainReportParamName, mainReportParamValue);

        //Sub Report
        pssub = c.prepareStatement("SELECT * from Language WHERE PrintLang = 'ENG' ");
        rssub = pssub.executeQuery();
        reportClientDocument.getSubreportController().setDataSource(subreportName, rssub);
        reportClientDocument.getDataDefController().getParameterFieldController().setCurrentValue(subreportName, "Pm-@PrintLanguage", "ENG");

        InputStream in = (InputStream) reportClientDocument.getPrintOutputController().export(ReportExportFormat.PDF);
        OutputStream out = new FileOutputStream("C:invoice.pdf");
        byte[] buf = new byte[1024];
        int len;
        while ((len = in.read(buf)) > 0) {
           out.write(buf, 0, len);
        }
        in.close();
        out.close();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if(null != c) {
            c.close();
        }
    }
}

我遇到以下错误:

Caused by: com.crystaldecisions.reports.common.MissingParameterValuesException: Some parameters are missing values
    at com.crystaldecisions.reports.dataengine.DataSourceManagerCoordinator.a(SourceFile:592)
    at com.crystaldecisions.reports.dataengine.DataSourceManager.if(SourceFile:1085)
    at com.crystaldecisions.reports.dataengine.DataSourceManager.a(SourceFile:1099)
    at com.crystaldecisions.reports.dataengine.DataProcessor2.a(SourceFile:734)
    at com.crystaldecisions.reports.formatter.formatter.objectformatter.ObjectFormatter.<init>(SourceFile:179)
    at com.crystaldecisions.reports.formatter.formatter.objectformatter.ObjectFormatter.if(SourceFile:135)
    at com.crystaldecisions.reports.formatter.formatter.paginator.PageFormatterBase.<init>(SourceFile:75)
    at com.crystaldecisions.reports.formatter.formatter.paginator.PageFormatter.<init>(SourceFile:183)
    at com.crystaldecisions.reports.formatter.formatter.paginator.PageFormatter.a(SourceFile:162)
    at com.crystaldecisions.reports.formatter.export2.a.a(SourceFile:202)
    ... 27 more
ERROR common - Failed to load the resource 'InternalFormatterException' from the bundle java.util.PropertyResourceBundle@4837635d.
java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key InternalFormatterException
    at java.util.ResourceBundle.getObject(Unknown Source)
    at java.util.ResourceBundle.getString(Unknown Source)
    at com.crystaldecisions.reports.common.CrystalResources.loadString(Unknown Source)
    at com.crystaldecisions.reports.common.CrystalResources.loadMessage(Unknown Source)
    at com.crystaldecisions.reports.common.CrystalResourcesFactory.getLocalizedMessage(Unknown Source)
    at com.crystaldecisions.reports.common.CrystalException.getLocalizedMessage(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.a(SourceFile:2257)
INFO  JRCLicenseThrottler -  releasing engine request
DEBUG commandmanager - command SETUP: NotUndoableCommand
DEBUG commandmanager - command PERFORM: NotUndoableCommand
DEBUG commandmanager - -- command is NOT UNDOABLE -> purge undo stack
com.crystaldecisions.sdk.occa.report.lib.ReportSDKParameterFieldException: InternalFormatterException---- Error code:-2147217394 Error code name:missingParameterValueError
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.if(SourceFile:237)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:147)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:128)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:111)
    at com.company.project.client.ui.controls.Test.printInvoice(Test.java:466)
    at com.company.project.client.ui.controls.Test.main(Test.java:400)

0 个答案:

没有答案