Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
After using Crystal Report and writing its associated Code and running it I am getting an Exception of "File Not Found". Thus I M Unable To Generate Reports.

How this Exception can be solved?
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
//using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

//using System.Data.SqlClient;
//using System.Configuration;
//using CrystalDecisions.Shared;
//using CrystalDecisions.CrystalReports.Engine;


namespace CrystalReportDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            CrystalReport1 cr = new CrystalReport1();
            EmployeeDataSetTableAdapters.EMPLYOEETableAdapter aa = new EmployeeDataSetTableAdapters.EMPLYOEETableAdapter();
            EmployeeDataSet.EMPLYOEEDataTable table = aa.GetData();
            cr.SetDataSource(table.DefaultView);
            crystalReportViewer1.ReportSource = cr;
            crystalReportViewer1.Refresh();

        }
    }
}



[Edit member="Tadit"]
Corrected formatting and grammatical issues.
Added pre tags.
Added correct Title and Description.
[/Edit]
Posted
v2
Comments
DamithSL 6-May-14 6:07am    
what is CrystalReport1? have you created .rpt file?
Member 10798032 6-May-14 10:13am    
CrystalReport1 is a .rpt file that have been created
Member 10798032 6-May-14 10:14am    
can u plzz let me knw how to mention locations for file and how to save them??
[no name] 6-May-14 7:53am    
Make sure that the "file that was not found" is able to be found.
ZurdoDev 6-May-14 8:10am    
Where should they look? Perhaps in the couch cushions?

1 solution

You didn't load the report file using ReportDocument object. Sample code should be like below
C#
private void button1_Click(object sender, EventArgs e)
{
    ReportDocument cryRpt = new ReportDocument();
    cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\\CrystalReport1.rpt");
    crystalReportViewer1.ReportSource = cryRpt;
    crystalReportViewer1.Refresh();
}

Check this tutorial & its series
C# Crystal Reports step by step[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900