Click here to Skip to main content
13,054,615 members (48,482 online)
Rate this:
Please Sign up or sign in to vote.
See more: , +

Am using crystal report in Win Forms. The record values fill in to data table, but not shown in report document.

How can recover this one?. Here my code.
How can recover this one?
Query = "Select StudentId, TypeofInome, CourseName, CourseFee, BookFee, Paid, Balance, BillNo, Total, Curdate from tblInc where BillNo  = '" + InvoiceNo + "'";
                  StrPath = AppDomain.CurrentDomain.BaseDirectory + "\\Report\\myCrystalRep.rpt";
                  ReportDocument ObjRepDoc1 = new ReportDocument();
                  SqlDa = new SqlDataAdapter(Query, SqlCon);
                  DataTable dt = new DataTable();
                  myCrystalRep myRep = new myCrystalRep();
                  myRep .SetDataSource(dt);
                  crystalReportViewer1.ReportSource = myRep ;
                  ObjRepDoc1.PrintToPrinter(NoofCopy, false, 0, 0);

Thanks in Advance
Posted 30-Mar-13 3:54am
Updated 31-Mar-13 1:04am
Prasad Khandekar 30-Mar-13 15:19pm
Have a look at this CP article (

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The order of coding is wrong.
First you should load the report file & then assign the ReportDocument to CrystalReportViewer. So it should be like below.
crystalReportViewer1.ReportSource = ReportDocument1;

And there's no need for PrintToPrinter method in your code because you wanted only to view the report.

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

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 30 Oct 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100