Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Crystal Reports 2008 - Changing Table Locations

Hello,

we have several reports which we use by different customers. The customers use different name spaces (table locations) for the same data. To use the same reports with different table locations, we wrote a piece of software replacing the connection strings and table locations.

-


Example:

A report should be used in a test environment as well as in a production environment:

The original SQL is (using a DB2 database on a AS400):

SELECT alias.name FROM as400.production.users alias

The modified SQL looks like:

SELECT alias.name FROM as400.test.users alias

-


Up to now we used Crystal XI and developed using RDC. We solved the above described problem by reading the report SQL string, replacing the table location in this string and assigned it back to the report object. Modifying the SQL string has the advantage that it works fine also for reports which contain a SQL command.

Since Crystal Reports 2008 this is not possible anymore (no RDC, no direct way to modify the report SQL string).

My first approach was to use the CrystalDecisions.CrystalReports.Engine.Table object. First I just wanted to see what really was the content of the Location and Name property:

for (int i = 0; i < rdReport.Database.Tables.Count; ++i)
{                    
  Table rt = rdReport.Database.Tables<i>;
  Console.WriteLine("Table Nr : {0}", i);                    
  Console.WriteLine("  Table Loc  : {0}", rt.Location);
  Console.WriteLine("  Table Name : {0}", rt.Name);
}

My problem with this is that the output for the report with the SQL in the above example is:

Table Nr: 0
  Table Loc : users
  Table Name: alias

So obviously not the real table location and table name is returned, but instead the table name for the table location and the alias for the table name. Unsurprisingly setting the location had not the originally desired effect.

Furthermore if the report was designed using a SQL command, the location and in the name property contain the string COMMAND. Therefore the table object doesn't seems to be the solution to my problem.

Thanks to the help of a user in this forum here, I figured out how to read the SQL string of a report. Unfortunately I did not found a way to assign it back to the report.

Has anybody here an idea how to solve my problem? I'm open for every kind of hint.

Thanks in advance,

Ron

Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question