Am working in a project where i should give a crystal reports RPT file as input and get the properties of that report.
But am facing a problem in loading the report itself so i have used isLoaded() function to check whether the report is loaded or not.
I have used the following code.
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 System.Web; using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; namespace sampleretreival { public partial class Form1 : Form { public string flName; public Form1() { InitializeComponent(); Retrieve.Enabled = false; } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (lstFiles.SelectedItems.Count > 0) { Retrieve.Enabled = true; } else { Retrieve.Enabled = false; } } private void Browse_Click(object sender, EventArgs e) { openFileDialog1 = new OpenFileDialog(); openFileDialog1.Multiselect = false; openFileDialog1.Filter = "Crystal Report Files | *.rpt"; openFileDialog1.ShowDialog(); flName = openFileDialog1.FileName; if (flName.Length != 0) { lstFiles.Items.Insert(0, flName); Retrieve.Enabled = true; } else { MessageBox.Show("Please select the crystal report files for analysis.", "SAMPLE", MessageBoxButtons.OK, MessageBoxIcon.Information); Browse.Focus(); } } private void Retrieve_Click(object sender, EventArgs e) { int a=1; ReportDocument rpt = new ReportDocument(); rpt.Load(flName); int count = 5; if (rpt.IsLoaded) { MessageBox.Show(count.ToString()); } else { MessageBox.Show(a.ToString()); } } } }
After compiling I clicked the Browse button to select the report from the disk. But when I click Retrieve button,program keep on running. Am not getting any output or any error.