1905301 - Table Alias name behaviour changed after Service Pack 4.NET SDK - how to handle the change

SAP Knowledge Base Article - Public

1905301 - Table Alias name behaviour changed after Service Pack 4.NET SDK - how to handle the change

Symptom

For example, if I change the table location from "Addresses"
to "Addresses_cws", the SQL returned is as below:-

ReportDocument reportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
reportDocument.Load(@"c:\Test.rpt");
ISCDReportClientDocument reportClientDocument = reportDocument.ReportClientDocument;

foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in reportDocument.Database.Tables)

    tbl.Location = "Addresses_cws";
    string sSqlDump = "";
    CrystalDecisions.ReportAppServer.DataDefModel.ISCRGroupPath groupPath = new CrystalDecisions.ReportAppServer.DataDefModel.GroupPath();
    reportClientDocument.RowsetController.GetSQLStatement(groupPath, out
    sSqlDump);

Resulting change:

*** SP3 ***
  SELECT DISTINCT "Addresses"."ID"
  FROM   "TestDB"."dbo"."Addresses_cws" "Addresses"

*** Since SP4 ***
  SELECT DISTINCT "Addresses_cws"."ID"
  FROM   "TestDB"."dbo"."Addresses_cws" "Addresses_cws"

Environment

Crystal Reports Developer for Visual Studio

Cause

This change was due to another Adpat: ADAPT01634300 - CR Net SDK - Database does not change using Report Engine.

Solution: So the issue is it does take the new name but when the report is exported to RPT format the old table name it not updated with the new table name.

Resolution

To resolve the Alias table name change the following updates to your code must be done:


            rd.Refresh();
            rd.VerifyDatabase();

            CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rcd = rd.ReportClientDocument;
            CrystalDecisions.ReportAppServer.DataDefModel.ISCRGroupPath groupPath = new CrystalDecisions.ReportAppServer.DataDefModel.GroupPath();
            string sSqlDump = "";
            
            CrystalDecisions.ReportAppServer.Controllers.DatabaseController dbctrl = rcd.DatabaseController;
            CrystalDecisions.ReportAppServer.DataDefModel.ISCRTable table = rcd.DatabaseController.Database.Tables[0];

            dbctrl.ModifyTableAlias(table, "Addresses");
            
            rcd.RowsetController.GetSQLStatement(groupPath, out sSqlDump);
            System.Console.Write(sSqlDump);


 

Keywords

Crystal Reports for Visual Studio, Table Alias name , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

Crystal Reports 2008 V1 ; SAP Crystal Reports, developer version for Microsoft Visual Studio