How can I retrieve the SQL SELECT statement used in an Crystal Report?

前端 未结 2 559
别跟我提以往
别跟我提以往 2021-02-06 09:19

I am currently working on a program in C# that allows our users to run, view and export a batch of Crystal Reports. The reports were made using the Crystal Reports 2008 GUI. One

2条回答
  •  旧巷少年郎
    2021-02-06 09:41

    I realize this is a very old question, but thought I would offer an alternative for those who stumble across this but need a framework target of 3.5 (dynamic is not available in 3.5).

    You will need the following references for this solution to work.

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

    Then just access the ClientDoc interface with the following and return a list of Command Text strings.

        private static List GetCommandText(CrystalDecisions.CrystalReports.Engine.ReportDocument report)
        {
            var rptClientDoc = report.ReportClientDocument;
            return rptClientDoc.DatabaseController.Database.Tables.OfType()
                  .Select(cmdTbl => cmdTbl.CommandText).ToList();
        }
    

提交回复
热议问题