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

Converting reports using internal data - no DB connect attempt #29

Open Jon-SSH opened 6 years ago

Jon-SSH commented 6 years ago

For some reason, the reports we are using cannot be converted with CrystalReportsNinja. My guess is that it's because the Database used in our reports is an ODBC connection. That said all the data needed to convert the rpt to a pdf is already in the report - I just need CRN to convert it to a PDF for me. For some reason 100% of my reports return the following error log:

03-08-2018  15:28:35    Report loaded successfully
03-08-2018  15:28:35    Output Filename : C:\Users\me\Downloads\report.pdf
03-08-2018  15:28:35    Output format : pdf
03-08-2018  15:28:35    Exception: Database logon failed.
03-08-2018  15:28:35    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)

Any advice would be appreciated!

mhertzfeld commented 6 years ago

Unless there is something special about your ODBC connection it should work.

What kind of a database are you connecting to?

Can you post the parameters you are passing into ninja?

You can try my fork of ninja. It expands some of the features and fixes a few issues.

https://github.com/mhertzfeld/CrystalReportsNinja

Jon-SSH commented 6 years ago

It's an IBM Informix ODBC connection. I am confidant the ODBC is working, as I am able to use regular Crystal Reports to view and edit.

I don't actually need the the database connection to be made, though - I have a Crystal Reports Server that generates a .rpt with all the information needed in it. That said, the feature you add to being able to email the report is exactly what I am attempting to do - and it would make me laugh to no end if it turns out I didn't actually need Crystal Reports Server.

mhertzfeld commented 6 years ago

I've worked with Informix a lot before so that will help in troubleshooting this.

Does crystal prompt you for credentials when you run the report in developer?

Are the login credentials saved in the ODBC DSN?

Are you passing the credentials for the database into ninja using the parameters?

If your end goal is to take a crystal report, run it through ninja and have it email the results to the users then I do not think you'l need Crystal Reports Server. I have never used Crystal Reports Server before and I have dozens and dozens of crystal reports that are emailed out to users daily. The users typically want the results in PDF but I also do a lot of Excels.

Jon-SSH commented 6 years ago

Haha, based on that, I bet we are using it in similar scenarios! I appreciate the assistance.

Initially, in order, Yes, No, Yes. I went ahead and added my creds to the DSN, and now the report no longer prompts for the creds, but CRN has the same issue as before - with or without credentials in the command. I'll go-ahead and give your fork a shot and let you know how it turns out.

Jon-SSH commented 6 years ago

Oh, wow, I'm an idiot. The informix DSN is 32-bit. I was using all 64-bit Crystal libraries and CRN.

I still think it should be a feature to skip the DB connection, and just process the report with the data in it.

mhertzfeld commented 6 years ago

Yeah a lot of people get hung up the 64/32 for ODBC connections and the crystal runtime.

So does that mean it is working for you now?

If you want that feature added, open an issue ticket on my fork and I will look into it the next time I have time to work on the project.

bushy555 commented 6 years ago

Hi, Recieved the same error message to an IBM Informix database --- Our issue was that the reports, created in Crystal Reports, simply did not have the 'data saved within the report' field ticked. As soon as I selected this, re-saved the report, Ninja went ahead, connected correctly straight to the ODBC name (without any of the -P -U -S -D parameters), and ran & exported the report correctly.

Just something else to look for : There was also another issue with another report / server settings based on the change of the database locale settings (About the 4th or 5th tab setting within the ODBC settings of the DSN parameters). All of our dates stored within this particular database are YYYY/MM/DD. By default this is "server" and "local" database locale : en_US.CP1252 and en_US.819. Someone had changed it to our local Aussie date format : en_au.8859-1 and en_US.819. ...and then when Ninja was trying to connect and run the Crystal report it was then trying to read the dates within the database as DD/MM/YYYY and simply falling over with weird messages that made no sense at all and had nothing to do with dates or anything. After a lot of mucking around, trial and error, as soon as I changed this locale thingy back to en_US.CP1252 and en_US.819, walla, away it went, connecting to the database correctly and running the report.

bushy555 commented 5 years ago

I've since noticed about the above, that Informix crystal reports do not automatically refresh, due to the 'save data within the report' field ticked. However, having this field turned off , (which I know is the proper method to make the reports auto run and auto refresh data), within our systems at least, both CRREPORT.EXE and NINJA.EXE simply fail to load Informix reports. Command line parameters are correct and are the same as those defined within the actual informix crystal report, as well as those within the informix ODBC settings. I have another old clunky crystal reporting program that refuses to work above Windows 2003, however, it runs these Informix Crystal Reports with the exact same command line parameters correctly (Database and host names). Changing the CREXPORT and NINJA parameters on purpose to be incorrect, makes no difference - they still both fail to load an Informix report with the 'save data within the report' field un-ticked; So, to me, it does kind of appear as though the command-line parameters are not being read or interpreted correctly for Informix databases. Truly truly weird and I can't get my head around why. Our only work around solution is to manually refresh the Informix crystal report, save, and re-run the batch file that runs & emails these particular reports. I have spent tens and tens of hours on this mucking around and fiddling trying different things with no progress yet....

SQL reports simply loads, work fine and auto refreshes as it should. I simply can't break any of our tens of SQL crystal reports.