Saturday, December 4, 2010

How To Create Crystal Report In C#

1). Create XML File That Used In this Reports.
So,How To Create That XML File.
1). To Creating that XML Using Dataset.
2). First Fill Dataset From DataAdapter.After That there is one property WriteXMLSchema Of Dataset.In this Property write the XML FIle Name.
2). After Creating that XML File.Right Click On Project And Click On  Add New Item.While Click On that One Open Dialog Box Appear.From that Dialog Box Click On Crystal Report.That will Add One Crystal Report On your Solution.
3). After Creating Rpt File Follows That Following Steps.
1). Add Datasource Of that newly created Crystal Report And Click On Database Expert… link.











2). Click On That One Dialog Box Appear that Describe below.
 


















3). When Expand that Database files Option It will ask the Location Of that XML give.Give the location Of that XML File.


















4). After Click On Open Button This Screen Appear.From That Choose the Table that will see on that Report.



















4). All This Task Complate That Write the below code For Bind the Data To ReportViewer .
ReportDocument rdoc = new ReportDocument();
// Path Of That Report Document File In Load Function Parameter.
rdoc.Load(@”C:\Documents and Settings\xosysadmin\My Documents\Visual Studio 2005\Projects\GivingXMLToRpt\GivingXMLToRpt\Testrpt.rpt”);
// Give the Dataset Name That Assing To Report Document
rdoc.SetDataSource(ds);
// Viewer Name . ReportSource = That Report Document Object Name
crystalReportViewer1.ReportSource = rdoc;