mhertzfeld / CrystalReportsNinja

A fork of a small Windows Console App that loads and executes Crystal Reports, exporting the results to a variety of supported file formats, email or printed. This fork includes numerous features and fixes that are not a part of the forked project.
25 stars 18 forks source link

Issue exporting certain reports to pdf #40

Open danielleevandenbosch opened 3 years ago

danielleevandenbosch commented 3 years ago

I have the following problem. I will describe what worked and what didn't. If it matters, the crystal reports connect to a Progress OpenEdge Database. The reports by themselves in the application SAP Crystal Reports 2016 natively works just fine. I have organized the error I am facing in the following spreadsheet. the main error message is as follows: `

08-04-2021 07:14:55 Message: Failed to retrieve data from the database.

Error in File Invoice 527611324{E0F1808B-40FA-41B2-87B2-535B32E0849D}.rpt: Failed to retrieve data from the database. Details: [Database Vendor Code: -210083 ] 08-04-2021 07:14:55 HResult: -2147221760 08-04-2021 07:14:55 Data: System.Collections.ListDictionaryInternal 08-04-2021 07:14:55 Inner Exception: System.Runtime.InteropServices.COMException (0x800002D3): Failed to retrieve data from the database.

`

https://drive.google.com/file/d/19VptgfVy83J65tdPfuEd7T9IriQwq-nD/view?usp=sharing

mhertzfeld commented 3 years ago

@danielleevandenbosch unfortunately problems with sub-reports are the most common issue reported for ninja and are difficult to troubleshoot because replicating the problem on my side is next to impossible. Someone would essentially have to recreate their report with the same issue using the adventure works database then send it to me so that I can run it myself in my development environment for me to really get anywhere figuring out the problem. I've tried creating a report with a few sub-reports that has an error but they always work. I think you saw the same thing in one of your scenarios where a report with a sub-report worked ok.

The Crystal Reports developer is a lot more forgiving when it comes to subreports than ninja. Even though on the backend their engines should be pretty similar.

Previously reported issues with subreports have been resolved by making changes to the crystal report itself. See issue 36 linked at the bottom as an example. You may want to start looking at how the sub-reports are linked.

In your successful test scenarios, were you connecting to the same database as you are in the scenario that failed?

is ninja running on the same computer as crystal developer? running as the same user?

How are you connecting to the database? ODBC? I haven't heard of Progress Openedge database before. Are you using the same authentication method for all your database calls?

How did you do the SQLs in your report? Are they all stored procedures? Custom SQL statements? Or SQLs crystal put together?

Searching around for the vendor code, only thing I could find was this. It doesn't help much, but it does hint that there may be some stale configuration data lurking in the crystal report in that specific scenario.

http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22156

Here are other links directly related to ninja you may want to check.

https://github.com/mhertzfeld/CrystalReportsNinja/issues/36

https://github.com/mhertzfeld/CrystalReportsNinja/issues/29

https://github.com/mhertzfeld/CrystalReportsNinja/pull/37

I gotta run now, but I will take another look at it tomorrow.

mhertzfeld commented 3 years ago

pinging @fabian-sta and @jostrander for their input.

fabian-sta commented 3 years ago

@danielleevandenbosch As per any issue, go back to basics If you can Duplicate the report and strip it down to the bare minimum and then build is back up ie. run with out any sub reports, then add one subreport and get it working Once that works From there should be easy going

danielleevandenbosch commented 3 years ago

It would seem at this time, I ended up solving the issue. Although this might come from my lack of knowledge of the inner workings of crystal reports, I ended up commenting out the line in the project under the run method the call to // PerformDBLogin();. I was assuming this was a vital part of the process and required to run the report.

mhertzfeld commented 3 years ago

Interesting.

Are you passing any of the following parameters when running ninja?

 Server Name
 Database
 User
 Password

I am wondering what the results would be if you left all those parameters out and ran ninja again with the PerformDBLogin(); method in play. Just glancing over the code but I think the results would be the same.

If you had the Server, DB, User and Password saved in the report it would probably make sense for the report to run ok without executing that function since it's essentially just passing the DB info and user info into the report prior to running it. However as long as what you're passing into ninja using the parameters is valid then it "shouldn't" make a difference. However, I have no clue on how the reports built so its all just guessing on my part. For all I know you could be calling a handful of different stored procedures each with a different user\password or even stored procs on different databases.

Regardless I am glad to hear it is working for you, that's the most important part.

mhertzfeld commented 3 years ago

As I look closer at the code called in that method, it's assuming that the Server, Database,User and Password will be the same value for each "table" in the crystal report. If they are different then I can see an error popping up.

Something like that will be tough to handle with the way parameters are passed into ninja. Off the top of my head, I'm thinking I'd have to add a configuration file option or something like that where the user could specify each "table" in the crystal and the DB Info and user credentials that go with each table.

Are you able to go through your report and check the DB info and User creds for each "table" to help confirm this theory?

danielleevandenbosch commented 3 years ago

I was actually leaving it all blank. The code below is the batch file I used(all 1 line). (Note I manually put the invoice.rpt file in the bin\debug directory) "C:\Users\itcon2\Documents\vandatatickets\1613\matthertfeld\CrystalReportsNinja\Source\CrystalReportsNinja\bin\Debug\CrystalReportsNinja.exe" -F "C:\Users\itcon2\Documents\vandatatickets\1613\matthertfeld\CrystalReportsNinja\Source\CrystalReportsNinja\bin\Debug\invoice.rpt" -a "invoiceid:101111" -a "CompNum:10" -a "PrintLanguage:EN" -E pdf -O invoice.pdf

danielleevandenbosch commented 3 years ago

So in my specific use case (And I might assume many others) each table uses the same database, user, password, and server. My question is (And you might be doing this already) can we create a parameter that will allow the user to skip the step PerformDBLogin(); I don't know what it would be called or how to define it in the help page. For the project I am working on, I simply commented it out as stated above and built the project.

jostrander commented 3 years ago

@danielleevandenbosch Does the latest change that got merged happen to fix the issue for you? I was struggling with an issue relating to database schema's not working in CRN versus the crystal reports software itself, and I found an old example where instead of completely overwriting the database credentials in PerformDBLogin(); we instead modify the existing database credentials by whats passed into the CLI if they are present. It was a small change, but what your describing sounds slightly similar.

mhertzfeld commented 3 years ago

I have started re-writing the PerformDBLogin function since it is a mess. Check the changes and let me know if you have any suggestions. Major change was adding another parameter for integrated security.

@jostrander Please post your changes so we can see what you had done on your end.

mhertzfeld commented 3 years ago

@danielleevandenbosch No rush. I haven't compiled yet, still have a few clean-ups I want to make.