Click here to Skip to main content
11,714,776 members (75,805 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: reporting-services , +

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
Edited 31-Mar-13 1:04am
Prasad Khandekar at 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
0 Sergey Alexandrovich Kryukov 570
1 Richard MacCutchan 275
2 Maciej Los 274
3 OriginalGriff 140
4 CHill60 135
0 Sergey Alexandrovich Kryukov 545
1 CHill60 375
2 Maciej Los 324
3 Richard MacCutchan 310
4 OriginalGriff 260

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 30 Oct 2013
Copyright © CodeProject, 1999-2015
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