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
94 stars 78 forks source link

Error with OLEDB for Oracle #15

Closed fmartiner closed 6 years ago

fmartiner commented 6 years ago

I receive the following error. The connection to the DB and the export of the report from CR is done correctly.

Report loaded successfully Database Login done Exception: Database Access Failed. Inner Exception: System.Runtime.InteropServices.COMException (0x8004100F): Database Access Failed. in CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext) in CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)

bxsx commented 6 years ago

@fmartiner have you already fixed it?

fmartiner commented 6 years ago

yes. Set the correct ORACLE_HOME and TNS_ADMIN.

bxsx commented 6 years ago

@fmartiner good to hear. I have the same issue. I have set both environment variables. While trying to connect directly from the code via Oracle.DataAccess it's working fine by using TNS. But its not working for database that is attached to the RPT file.

Do you pass arguments to the application or everything is working automatically? I use Oracle 11.2.0. In my tnsames.ora I have specified:

TEST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = DBSID)
    )
  )
fmartiner commented 6 years ago

@bartskowron Yes I pass -U, -P and -S argument whenever I launch the export. Use the SERVER ORACLE in Crystal Reports and instal th oracle client on computer. I set this in .bat file with set command

Example file bat: set ORACLE_HOME=C:\Oracle\Client\product\12.1.0\client_1 set TSN_ADMIN=C:\Oracle\Client\product\12.1.0\client_1\network\admin CrystalReportsNinja.exe -F report.rpt -U user -P password -S TEST -O report.pdf -E pdf

bxsx commented 6 years ago

Unfortunately, I have no access to the CRDeveloper but I can ask someone to take a look there etc. I know that in RPT the connection is set by using OLE DB (ADO) - which appeared after installing ODAC. Do you mean to change it to "SERVER ORACLE" connection? What is required to get this kind of connection in CrystalReports then?

Also what do you mean by installing the oracle client? I have installed ODAC and Oracle Developer Tools for Visual Studio 2017. I believe the Oracle Client is bundled here but unfortunately I am not .NET/Oracle developer so I don't have experience enough to understand all shortcuts ;-) I think my ORACLE_HOME points to the ODAC - C:\Oracle\product\11.2.0\client_1

As I said, I easily connected to the DB from .NET/C# by using Oracle.ManagedDataAccess.Client (I wrote wrongly before that I use Oracle.DataAccess which actually didn't work for me, so switched to the Managed version).

sunk818 commented 6 years ago

Set up odbc dsn that's points to Oracle drivers.