How to obtain The Oracle Package name from a Crystal Report file using .NET code

本秂侑毒 提交于 2020-01-25 22:11:33

问题


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



来源:https://stackoverflow.com/questions/2373321/how-to-obtain-the-oracle-package-name-from-a-crystal-report-file-using-net-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!