How to obtain The Oracle Package name from a Cryst

2019-08-17 10:42发布

问题:

I'm trying to obtain the Oracle package name used for a Crystal report data source using .NET code. I have obtained the procedure name, but for some reason I can not find the package name.

     Dim rpt as new ReportDocument
     rpt.Load(filename)

     Dim procedureName As String = rpt.Database.Tables.Item(0).Location 
     Dim DataSourceAliasName As String = rpt.Database.Tables.Item(0).Name

Currently using .NET Crystal Decisions version: 10.5.3700.0

回答1:

The QualifiedName attribute is not exposed on the public dotnet wrapper. You have to access the non-public underlying COM object and use that.

You need to reference the following DLLs:

CrystalDecisions.CrystalReports.Engine
CrystalDecisions.ReportAppServer.DataDefModel

Below is an example code snippet. Note that it will come back prefixed with the schema name. I ended up chopping that off in my real implementation.

using System;
using System.Reflection;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportAppServer.DataDefModel;

namespace ConsoleApplication1
{
   class Program
   {
      static void Main(string[] args)
      {
         ReportDocument doc = null;
         CrystalDecisions.CrystalReports.Engine.Table table = null;
         PropertyInfo prop = null;
         ISCRTable rasTable = null;

         doc = new ReportDocument();
         doc.Load("c:\\workspace\\temp\\example.rpt");
         table = doc.Database.Tables[0];

         prop = table.GetType().GetProperty("RasTable",BindingFlags.NonPublic | BindingFlags.Instance);
         rasTable = (ISCRTable)prop.GetValue(table, null);

         Console.Out.WriteLine(table.Name);    
         Console.Out.WriteLine(rasTable.QualifiedName);

      }
   }
}


回答2:

Have you tried setting a break point, and viewing the contents of rpt.Database.Tables.Item(0)?

Update: Here is a list of some properties: Crystal Reports