cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot ApplyLogOnInfo on a table in a Read-Only RPTR Report

Former Member
0 Kudos

I'm using a Crystal Report Viewer in my .Net app and i use the following code to relocate tables in my 'normal' RPT reports:

           With crConnectioninfo

                .ServerName = <<DSN Name>>

                .DatabaseName = <<Database Name>>

                .UserID = <<ODBC User ID>>

                .Password = <<ODBC User Password>>

            End With

            crRpt.Load(<<Full path to Crystal Report>>)

            crTables = crRpt.Database.Tables

            Dim crTable As CrystalDecisions.CrystalReports.Engine.Table

            For Each crTable In crTables

                crTableLogoninfo = crTable.LogOnInfo

                crTableLogoninfo.ConnectionInfo = crConnectioninfo

                crTable.ApplyLogOnInfo(crTableLogoninfo)

            Next

              ReportViewerCR.ReportSource = crRpt

It all works perfectly when i use a 'Normal' Crystal report i.e. any RPT file

However, when i use a Read-Only Crystal Report, RPTR, the code fails at the line

crTable.ApplyLogOnInfo(crTableLogoninfo)

and i get the following error message:

"Illegal operation on Crystal Reports Read-Only (RPTR) report. Please check release notes to get more information"

Can anyone please help?

Many thanks,

Jan

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor
0 Kudos

RPTRs are read only.  This means that they cannot be refreshed, so they cannot connect to a database.  That is why you're getting the error - the report should be viewable without setting the logons.

-Dell

Former Member
0 Kudos

Thanks Dell, for the reply.

I understand that RPTR's are read-only but here's the issue:

I've designed a report (RPT) and then converted it to Read-Only (RPTR) for someone that has 5 IDENTICAL databases (on the ONE SQL Server).

Therefore, the user should be able to run the report on ANY of the 5 databases (on the same server) as they all have the same tables/views/st procs.

In my application, i simply want to change the database (1 of 5) that the user should connect to when they want to run my report. Hence my, 'ApplyLogonInfo'

I'm not altering the structure of the report...... just setting it to point to a particular database.

If i can't change the database, do i have to create 5 Identical reports? Each pointing to a different database? sounds a bit extreme.....

Any ideas?

Many thanks

- Jan

ido_millet
Active Contributor
0 Kudos

One solution is to use an rpt file instead of an rptr file.

An alternative is to use a different protection scheme for the rpt.

That's the approach I use in my viewer app, which can switch data sources for the protected files.

DellSC
Active Contributor
0 Kudos

You can't do it with an RPTR.  The purpose of RPTR files is to save reports that have data included so that users can view them without connecting to the database.  They're not meant for running reports.

-Dell

Former Member
0 Kudos

Thanks Ido,

Using RPT files works perfectly within my app. My app properly re-allocates the databases.

The problem only lies with RPTR (Read-Only) files.

I take your point on-board about using rpt files..... but...... there's always a 'bright spark' at the end-users' place who thinks they know Crystal reports and try to alter your hard worked reports..... and end up screwing it up.....

That was why i though RPTR would be a god-send..... if your end-users cannot modify them.

But then, I cannot re-allocate the database (tables) in a .NET app for RPTR files.... which seem to defeat the purpose of RPTR files

What other (alternative) protection scheme do you recommend?

Any help will be greatly appreciated.

- Jan

Former Member
0 Kudos

Thanks Dell,

I read an article (see attached) which says that RPTR reports can be refreshed (but the structure cannot be modified).

I'm fine with not modifying them.

Just need to point them to different databases in .NET code......like we do with RPT files...

Any ideas?

Thanks

- Jan

ido_millet
Active Contributor
0 Kudos

Dell, my viewer application can refresh data in RTPR files.  So I believe RPTR are designed to allow that.

DellSC
Active Contributor
0 Kudos

Interesting.... That's cool.

-Dell

former_member183750
Active Contributor
0 Kudos

By design, RPTR files can only connect and be refreshed if used with the same datasource as when the report was created. E.g.; your datasource is ODBC called test, you will not be able to connect to ODBC called test2. Nor can you change the connection method, etc. From the SAP Crystal Reports .NET SDK Developer Guide:

Working with Crystal Reports Read-Only (RPTR) reports



Crystal Reports Read-Only (RPTR) reports are Crystal reports that can be viewed with report viewer applications, but cannot be modified with the SDK or opened by report designer applications. This lets you protect your intellectual property by preventing users from modifying the report or obtaining information about proprietary business logic stored in the report definition.

Crystal Reports Read-Only format reports use the RPTR file extension instead of the RPT file extension used by Crystal reports. You can create an RPTR report by exporting an RPT report to RPTR format. However, there is no supported way to convert an RPTR report to an RPT report.

Because the definition of an RPTR report cannot be modified, you cannot use this SDK to set the data source location of an RPTR report through the database controller. However, you can refresh the data of an RPTR report at run time.

  • You can use this SDK to perform the following tasks:
  • Create an RPTR report by exporting a Crystal report (RPT) to RPTR format. 
  • View an RPTR report by obtaining its report source and passing the report source to a viewer.
  • Refresh the data of an RPTR report at run time.
  • Open an RPTR report, and export it to formats other than RPT.

You cannot use this SDK to perform the following tasks:

  • Modify the report definition of an RPTR report.
  • Set the data source location of the report.
  • Retrieve information about the report definition of an RPTR report, including the formulas, fields, sections, and objects that make up the report.
  • Export an RPTR report to RPT format.
  • Add an RPTR report as a subreport to an RPT report.

 

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Former Member
0 Kudos

Thank you Ludek, for that clarification. Much appreciated.

I think RPTR reports are a fantastic idea, especially for developers to protect their intellectual property and more importantly, from users trying to modify the reports without clearing it with the developers.

However, i suppose it can go onto the "Wish List" - that developers should ideally be able to alter the logoninfo for the RPTR reports so that it can be used on multiple databases (albeit, without anyone being able to change the content/structure of the report - Developers can insert a (c) Copyright notice in the report, without the users being able to remove the copyright notice )

Regards,

- Jan

former_member183750
Active Contributor
0 Kudos

Hi Jan

I could easily go with that suggestion . SAP has a thing called the SAP Idea Place where you can suggest enhancements. I think ideas coming from customers carry a bit more weight than ideas from me, so if you want to... Let me know and I can tweet the idea, get it voted up and then we keep our fingers crossed.

- Ludek

Former Member
0 Kudos

Thanks Ludek....... yes, please tweet my suggestion. If it makes life

easier for developers, then I'm all for it....

My suggestion is as follows:

RPTRs are a fabulous idea.... however, the developer that develops the rpt

should have an option of exporting to RPTR with one of the following options:

1. Completely lock down the report to ONE DSN AND ONE DATABASE

Or

2. Lock down the report but allow the user (or another developer) to change the DSN and db location (BUT NOT ALTER

      THE REPORT IN ANY WAY)

OR

3. Lock down the report and don't allow the user to change the DSN but DO allow change of db

In all the  above cases, the original developer should be able to insert a copyright notice within the report that no-one

should be able to remove once converted to an RPTR. Copyright notice could appear as a 'Special Field'

The above, hopefully, is not too much to ask......

Best regards,

- Jan

former_member183750
Active Contributor
Former Member
0 Kudos

Millet,

   Yes i am also able to refresh report data using

Reportdocument.Refresh()

I am working on Oracle database with same DSN and User ( changing database in Tnsnames)

but it prompts for Password since dsn does not store the database password.

Please suggest if there is any way we can pass the password from code and suppress the prompt

Thanks in advance

Vinod

Answers (0)