Question

I've got 2 applications:

    1. App to prepare data for reporting - C# (.Net 1.1)
    2. App to display report - C++ (maybe)

First app send parameters such a report file name, report parameters to second app via command line. Then second app display prepared report.

Now I want to change some report fields. My code in 1st app:

ReportDocument rDoc = new ReportDocument();
rDoc.Load(@"D:\reports\report_1.rpt");
rDoc.Database.Tables[0].Location = "newDBName.schema.oldTableName";
rDoc.SaveAs(@"D:\reports\report_1_modif.rpt",ReportFileFormat.VSNetFileFormat);

I want to modify rpt file because I want to take data from the archive database. "CrystalDecisions.CrystalReports.Engine" reference version is 9.1.5000.0. So 2nd app can't use modified rpt file because of incompatible versions. 2nd app can work only with 8.5 file formats.

When I open rpt file in CR Developer I can manually change location and save in 8.5 file format. In this case 2nd program normally works with modified file.

So my question is: "How can I in .Net C# open rpt file 8.5, modify and save in 8.5 format with another name?". Maybe I should use some unmanaged code?

Crystal Reports 8.5 was released in 2001. .Net in 2002.

Was it helpful?

Solution

I solved problem. My approach:

  1. In C# code we update set of synonyms in DB after every user click "show report". After update each synonym still has the same name but follows to another table in different database.
  2. We modified CR 8.5 file by hands: a) changed connection type to OLE DB (Native SQL Client) because of ODBC layer don't support synonyms b) set synonyms as tables locations instead of full table names.
  3. Task solved!

UPD. We need p2soledb.dll to use OLE DB.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top