Here, I have created a crystal report with some fields of the database object i.e. product_id, product_name, product_quantity from product table.
After creating a report you have to host it in your application. Steps for hosting crystal report in an application.
· Drags the Crystal Report Viewer control from toolbox drop it into windows form.
· Drag the button from toolbox and drop it into windows form.
· Use namespaces in your application as given below:
· On the click event of button write some code as mentioned below:
private void button1_Click (object sender, EventArgs e)
ReportDocument cryRpt = new ReportDocument ();
cryRpt.Load ("D:\\rohit\\crystal reports\\CrystalReport1.rpt"); //crystal report
crystalReportViewer1.ReportSource = cryRpt;
After performing the above tasks you can see the output by running your application.
Click on the Show Report button to see a report.