Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: reporting-services , +
Hi,
 
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();
                    dt.Clear();
                    SqlDa.Fill(dt);
                    myCrystalRep myRep = new myCrystalRep();
                    myRep .SetDataSource(dt);
                    crystalReportViewer1.ReportSource = myRep ;
                    crystalReportViewer1.Refresh();
                    ObjRepDoc1.Load(StrPath);
                    ObjRepDoc1.PrintToPrinter(NoofCopy, false, 0, 0);
Thanks in Advance
Posted 30-Mar-13 4:54am
Edited 31-Mar-13 2:04am
v2
Comments
Prasad Khandekar at 30-Mar-13 15:19pm
   
Have a look at this CP article (http://www.codeproject.com/Articles/28899/Crystal-Report-with-DataSet-and-DataTable-using-C).

1 solution

Rate this: bad
good
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.
ReportDocument1.Load(StrPath);
crystalReportViewer1.ReportSource = ReportDocument1;
crystalReportViewer1.Refresh();
And there's no need for PrintToPrinter method in your code because you wanted only to view the report.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 230
2 BillWoodruff 205
3 DamithSL 165
4 Sergey Alexandrovich Kryukov 155
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,650
3 Kornfeld Eliyahu Peter 3,460
4 Sergey Alexandrovich Kryukov 2,811


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 30 Oct 2013
Copyright © CodeProject, 1999-2014
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