0

I am trying to export crystal report into pdf in Windows Form application.My Crystal Report is getting data from the Mysql Database.Here is my code for the same..

        ReportDocument doc = new ReportDocument();
        doc.Load("CrystalReport1.rpt");
        doc.SetDataSource(dttable);

        SaveFileDialog saveas = new SaveFileDialog();
        saveas.Filter = "*.pdf|(PDF File)";
        if (saveas.ShowDialog() == DialogResult.OK)
        {

            doc.ExportToDisk(ExportFormatType.PortableDocFormat, saveas.FileName + ".pdf");
            MessageBox.Show("Report Exported !");

        }

On running the above code. I am getting error

'Load report failed' at line doc.Load("CrystalReport1.rpt");

Please help me resolve this.

Dyrandz Famador
  • 4,499
  • 5
  • 25
  • 40
Ram
  • 545
  • 6
  • 16
  • 28

2 Answers2

2

I think the error seems to be the path of your report.

Let's try this:

doc.Load(AppDomain.CurrentDomain.BaseDirectory + "CrystalReport1.rpt");

Ludo

ludocal
  • 141
  • 3
  • CrystalReports Exception was unhandled by user code.Load report failed – Ram Mar 14 '14 at 10:20
  • Let's try the full path of your file, like "C:\...\CrystalReport1.rpt" – ludocal Mar 14 '14 at 10:26
  • CrystalReport1.rpt is in my Visual Studio Project folder – Ram Mar 14 '14 at 10:27
  • what is the problem sir .Please tell me.Is it happening because of permission issue – Ram Mar 14 '14 at 10:37
  • Your application running in "\bin\Debug" folder and your report is in your Visual Studio Project folder. Crystal report try to open "Visual Studio Project folder\bin\debug\CrystalReport1.rpt" and it found nothing. Your best option is to set "Copy to Output Directory" to "copy always" of the property report and your report will be in /bin/debug. – ludocal Mar 14 '14 at 11:04
  • Could not load file or assembly 'file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.This is the error that i am getting now. – Ram Mar 14 '14 at 11:15
  • look this post http://stackoverflow.com/questions/6601741/could-not-load-file-or-assembly-crdb-adoplus-dll – ludocal Mar 14 '14 at 11:18
0
try
{
    ReportDocument rpt = new ReportDocument();
    rpt.Load(@"D:<path>\Graduation System\Graduation System\graduatedstudents.rpt");
    CRV1.ReportSource = rpt;
    CRV1.Refresh();
}
catch (Exception ex)
{
    throw;
}

I am facing load report error

Kevin
  • 16,696
  • 7
  • 51
  • 68
  • 2
    I'm not sure, but this post seems to be asking a new question instead of answering this question. If this is the case, please post a new question. – tjd Apr 09 '15 at 15:01