locked
Error while export crystal report to pdf file RRS feed

  • Question

  • Dear All,  

            I am trying to export crystal report to pdf file for this i wrote the code.

     

       ReqSlip Rpt = new ReqSlip();

       Rpt.SetDatabaseLogon("sa", "dbserver", "dbserver", "IMS");

       Rpt.RecordSelectionFormula = "{ReqSlipRptPrint.ReqSlip_ID} = 15 ";

       if (System.IO.File.Exists("Details.pdf"))

      {

                 System.IO.File.Delete("Details.pdf");

      }

     ExportOptions CrExportOptions;

                        DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();

                        PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();

                        CrDiskFileDestinationOptions.DiskFileName = "Details.pdf";

                        CrExportOptions = Rpt.ExportOptions;

                        {

                            CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;

                            CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                            CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;

                            CrExportOptions.FormatOptions = CrFormatTypeOptions;

                        }

     

                        Rpt.Export();    

    But it produced an error :

     

    Failed to open a rowset.

    Details: ADO Error Code: 0x

    Source: Microsoft OLE DB Provider for SQL Server

    Description: Could not use view or function 'IMS.dbo.ReqSlipRptPrint' because of binding errors.

    SQL State: 42000

    Native Error: 

     

    Could you please help me out.

    Thanks 

    • Moved by CoolDadTxModerator Monday, July 18, 2011 1:14 PM CR related (From:Visual C# IDE)
    Monday, July 18, 2011 11:20 AM

All replies

  • Hello,

    After you declare the report object you must load it:

    ReqSlip Rpt = new ReqSlip();

                CrystalDecisions.CrystalReports.Engine.ReportDocument  Rpt = new ReqSlip();
                Rpt.Load(ReqSlip);

    Also, is your report using that same connection info?

    Don

     

     


    Don Williams
    Monday, July 18, 2011 3:00 PM