rainforestnet / CrystalReportsNinja

A small Windows Console App that loads external Crystal Reports file, takes parameter inputs and export to various format or even print to printer
http://www.rainforestnet.com
93 stars 77 forks source link

Reports with subreports generating "Operation illegal on linked parameter" #48

Open lunarindustrial opened 4 years ago

lunarindustrial commented 4 years ago

Hello, I'm getting an error when generating a report which has subreports.

The report in question has two subreports. The subreports were setup on links internal to the database, so the report's parameter fields were not passed to the subreports. I received the following error:

C:\CRNinja\CrystalReportsNinja.exe -S DB_DSN_64 -F C:\MyReports\MyCrystalRep.rpt -O C:\OutReport\MyCrystalRepAUG19 -E PDF -a "Client Code:5055" -a "Beginning Date:2019-08-30 00:00:00" -a "Ending Date:2019-08-30 00:00:00" Report loaded successfully Database Login done Error in File MyCrystalRep 41485204{7C937E7A-96D0-4676-B3C2-B68DD64B9DE2}.rpt: Operation illegal on linked parameter. Error in File MyCrystalRep_ 41485204{7C937E7A-96D0-4676-B3C2-B68DD64B9DE2}.rpt: Operation illegal on linked parameter. at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext) at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)

So, I took out one subreport and changed the other to work with a pass-through parameter (the Client Code from the command line).

However, the same error was generated. I'm using CR 2016, and the CRNinja file version as of 8/20/2018

Is CRNinja not working with subreports at this time?

Thanks in advance.

mhertzfeld commented 4 years ago

Try my fork of the project. It has features and bug fixes the main project does not have. Fixing sub reports in one of the areas of focus the past month.

https://github.com/mhertzfeld/CrystalReportsNinja

lunarindustrial commented 4 years ago

Thanks! Unfortunately, it's pulling up a different error:

Exception: Could not load file or assembly 'CrystalDecisions.CrystalReports.Engine, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified. Inner Exception:

mhertzfeld commented 4 years ago

Check to make sure you are using Crystal Reports Runtime 13.0.24

If you are using a previous version of the runtimes you should uninstall the runtime and install the new version of the runtime.

If you are unable to use the new version of the runtime you can try to compile for the runtime version you are using but I would not recommend that.

Also be sure to check the documentation as there have been changes to the parameters.

lunarindustrial commented 4 years ago

OK, thanks. I will take a look at and try your first scenario.

lunarindustrial commented 4 years ago

OK, I updated the runtime version to 13.0.24. Reports without subreports run fine. But, reports with subreports fail with the following error:

Exception: Error in File MyCrystalReport_ 38842548{C7290FBF-98E9-4BF4-AF64-E6E23C808EF5}.rpt: Unable to connect: incorrect log on parameters. Inner Exception: System.Runtime.InteropServices.COMException (0x8004100F): Error in File MyCrystalReport_ 38842548{C7290FBF-98E9-4BF4-AF64-E6E23C808EF5}.rpt: Unable to connect: incorrect log on parameters. at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext) at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)

It seems that the subreports want their own login parameters?

mhertzfeld commented 4 years ago

Is the connection in the primary report and sub report the same?

What type of connection are you using? ODBC, OLE, ect…

What type of database are you connecting to?

Can you describe the report? How may sub reports?

Are you passing the log in parameters to ninja, or are you using integrated security?

lunarindustrial commented 4 years ago

The connection is the same, both the report and sub-report use an ODBC 32-bit system DSN with Windows authentication. Crystal won't work with a 64-bit ODBC connection.

The connection is to a MS SQL 2014 database. The report was using two sub-reports. Both sub-reports were linked to the main report via internal database key fields, not based on parameter fields.

I chopped out one as an experiment, and just ran the report with one sub-report, but still no luck. I then changed that sub-report's links to use the main report's parameter field for "Client Code" instead of an internal database key field, but still no luck.

I am not passing the login parameters to CRNinja, instead I am using an ODBC 64-bit system DSN with Windows authentication. CRNinja won't use a 32-bit ODBC connection.

Here is the command-line I'm using:

C:\CRNinja\CrystalReportsNinja.exe -S DB_DSN_64 -F C:\MyReports\MyCrystalRep.rpt -O C:\OutReport\MyCrystalRep_AUG19 -E PDF -a "Client Code:5055" -a "Beginning Date:2019-08-30 00:00:00" -a "Ending Date:2019-08-30 00:00:00"

I'm wondering if the fact that Crystal and CRNinja have to be on different bit ODBC connections has something to do with the issue?

mhertzfeld commented 4 years ago

Ninja can use a 32bit ODBC DSN if you use the version of ninja compiled for 32bit. See the link below. As long as I didn't make a mistake when I compiled it, that should be a 32bit compile that will use a 32bit ODBC DSN.

I'm assuming you are using the 32bit DSN when testing the report in the Crystal Developer. If so and if the DSN name is the same where you are running Ninja, try not passing that parameter into Ninja.

https://github.com/mhertzfeld/CrystalReportsNinja/tree/master/Deployment/32-bit

lunarindustrial commented 4 years ago

Unfortunately, it didn't do the trick. The new exe is throwing an error regardless of the bit-size (I tried both 32 and 64), and even with a report without any sub-reports:

Exception: The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception. Inner Exception: System.IO.FileNotFoundException: Could not load file or assembly 'CrystalDecisions.ReportAppServer.CommLayer, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified. File name: 'CrystalDecisions.ReportAppServer.CommLayer, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' at CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor()

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

lunarindustrial commented 4 years ago

However, I didn't try it yet without eliminating the DSN parameter altogether. Let me try that, first.

lunarindustrial commented 4 years ago

Unfortunately, still no go. If I take out the -S server parameter I get the failed login error:

Exception: Database logon failed. Inner Exception: System.Runtime.InteropServices.COMException (0x8004100F): Database logon failed. at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext) at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)

mhertzfeld commented 4 years ago

At the moment I do not have a testing enviroment setup to help troubleshoot this.

I am planning on building a new developement and testing enviroment in azure sometime in the near future, maybe this weekend. Once I get that up and running I will try to replicate the problem you have described.

lunarindustrial commented 4 years ago

OK, let me know if you need any other details, or if there is a specific syntax I should use for testing.

mhertzfeld commented 4 years ago

I've almost completed my development environment in azure.

If possible, can you create a new report with the same problem using the AdventureWorks sample database, then send me the crystal report? That way I can troubleshoot the exact problem you are seeing?

https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks

lunarindustrial commented 4 years ago

mhertzfeld, thanks for the help. Please give me a few days to get that together. I don't have AdventureWorks on the server, so I'll need to make a few tables with test data, along with a replicated report for those.

ingridMRG commented 1 year ago

Thanks for your fork @mhertzfeld it worked for me and it is been printing reports except when I have subreports , this is message about parameters and then it said it exported it

Number of Parameters detected in the report = 10 14-02-2023 08:41:24 Number of Parameters passed by the users script = 6 14-02-2023 08:41:24 14-02-2023 08:41:24 Applied Parameter 'P_TITLE' as MultiValue 'False' 14-02-2023 08:41:24 Discrete Parameter : P_TITLE = Whole File 14-02-2023 08:41:24 Single Value Parameter - Prompt = - P_TITLE = Whole File 14-02-2023 08:41:24 14-02-2023 08:41:24 Applied Parameter 'P_PERIODID' as MultiValue 'False' 14-02-2023 08:41:24 Discrete Parameter : P_PERIODID = 71077 14-02-2023 08:41:24 Single Value Parameter - Prompt = - P_PERIODID = 71077 14-02-2023 08:41:24 14-02-2023 08:41:24 Applied Parameter 'P_RECALLID' as MultiValue 'False' 14-02-2023 08:41:24 Discrete Parameter : P_RECALLID = 0 14-02-2023 08:41:24 Single Value Parameter - Prompt = - P_RECALLID = 0 14-02-2023 08:41:24 14-02-2023 08:41:24 Applied Parameter 'P_SORTOPTION' as MultiValue 'False' 14-02-2023 08:41:24 Discrete Parameter : P_SORTOPTION = 1 14-02-2023 08:41:24 Single Value Parameter - Prompt = - P_SORTOPTION = 1 14-02-2023 08:41:24 14-02-2023 08:41:24 Applied Parameter 'P_OPTION' as MultiValue 'False' 14-02-2023 08:41:24 Discrete Parameter : P_OPTION = AUTH DHC RGI 14-02-2023 08:41:24 Single Value Parameter - Prompt = - P_OPTION = AUTH DHC RGI 14-02-2023 08:41:24 14-02-2023 08:41:24 Skipped 'P_PERIODID' as MultiValue 'False' Parameter in SubReport = 'InvoiceSummary' as its Linked to Main Report 14-02-2023 08:41:24 14-02-2023 08:41:24 Skipped 'P_RECALLID' as MultiValue 'False' Parameter in SubReport = 'InvoiceSummary' as its Linked to Main Report 14-02-2023 08:41:24 14-02-2023 08:41:24 Skipped 'P_PERIODID' as MultiValue 'False' Parameter in SubReport = 'kroger_summary' as its Linked to Main Report 14-02-2023 08:41:24 14-02-2023 08:41:24 Skipped 'P_RECALLID' as MultiValue 'False' Parameter in SubReport = 'kroger_summary' as its Linked to Main Report 14-02-2023 08:41:24 14-02-2023 08:41:24 Skipped 'P_INVOICEID' as MultiValue 'False' Parameter in SubReport = 'kroger_summary' as its Linked to Main Report 14-02-2023 08:41:24 14-02-2023 08:41:24