【问题标题】:Fetch single row from SQL DB using Crystal Reports使用 Crystal Reports 从 SQL DB 中获取单行
【发布时间】:2015-08-01 23:34:12
【问题描述】:

我遇到了一个问题,我的水晶报表正在为每条记录创建 pdf 页面,尽管数据表被解析为仅包含一行的 pdf 生成。

我有一个查询,它根据 Id 选择单行,然后将其放入数据集数据表中并解析为水晶报表生成。

通过我可以确认数据表只包含一行,但输出的是pdf的多页,每页显示不同的行。

以前有没有人遇到过这种情况,如果有,是什么导致我的数据表被写入?

背后的代码:

public string CreateMaster(int Id)
        {
            DataTable dt = DataGrabber(Id);// returns a dataset
            ExportOptions expo = new ExportOptions();
            PdfRtfWordFormatOptions form = new PdfRtfWordFormatOptions();
            string op = "";
            string smp = DateTime.Now.ToString("yyyyMMddHHmm");
            DiskFileDestinationOptions dfd = new DiskFileDestinationOptions();
            op = @"E:\SomeFolder\Client_ID" + Id + "_TS"+ smp + ".pdf";

            using (ClientDdPdf pdf = new ClientDdPdf())
            {
                pdf.PrintOptions.PaperOrientation = PaperOrientation.Portrait;
                pdf.PrintOptions.PaperSize = PaperSize.PaperA4;
                pdf.SetDatabaseLogon(DbUser,DbPass,DbServer,DbDb);
                pdf.SetDataSource(dt); // confirmed that the single datatable from dataset is parsed
                dfd.DiskFileName = op;
                expo = pdf.ExportOptions;
                expo.ExportDestinationType = ExportDestinationType.DiskFile;
                expo.ExportFormatType = ExportFormatType.PortableDocFormat;
                expo.DestinationOptions = dfd;
                expo.ExportFormatOptions = form;
                pdf.Export(expo);
            }
            ReadPdfFile(op);
            return op;
        }

【问题讨论】:

    标签: c# pdf datatable crystal-reports


    【解决方案1】:

    不完全确定为什么会出现这个问题,但它不喜欢我正在解析的自定义查询,因为水晶报表中已经有查询。

    为此找到的解决方案是将水晶报表映射到视图。本质上,这仍然是从相同的表中获取相同的字段,但它确实获取了数据表中的解析并生成了所需的字段。

    澄清一下,我根本没有更改我的代码,我仍然使用相同的查询来获取必要的数据表,但是在将水晶报表绑定到数据库时,我没有将它绑定到表,但改为我创建的视图。

    【讨论】:

      猜你喜欢
      • 2012-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多