Crystal Report in .net support two methods
1) PULL Method:
Using Pull Method ,Crystal Report is directly connected to data source and can retrieve data without providing connection details and SQL commands.This details are configured during designing of Crystal Reports.
Using Push Method,Crystal Report is connected to data-set and data-set to Data-source.To connect to data-source user have to provide connection details and SQL Commands to retrieve data.
Here I am Using PUSH Method to create Crystal reports.
I will show step by step creating Crystal reports.
Install SAP Crystal report and configure with visual studio.
Now go to your project and Right Click on project and select add new Item and Select Crystal report
New Window will open choose Blank Report
Now, Add new data set to project & add new table.
Go Back to Crystal report and from field explorer tab .right click on 'Database Fields' and database expert following window will open then select data set from list and add to right side
Design your report as you required and drag and drop required field from data set.
Add new form to your project and drag and drop crystal report viewer to your new form
In code write the following code
public partial class Form1 : Form
DataTable dt ;
private void Form1_Load(object sender, EventArgs e)
//Create new report Document
ReportDocument rptDoc = new ReportDocument();
//Create new instance of Dataset
DataSet1 ds = new DataSet1();
//get Data from db
//merge data in dataset
//get path of crystal report
string srtPath = Application.StartupPath.ToString() + "\\CrystalReport2.rpt";
crystalReportViewer1.ReportSource = rptDoc;
private DataTable funGetData()
dt = new DataTable();
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationSettings.AppSettings["ConnString"].ToString();
string query = "select * from tbEmp";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
catch (Exception ex)
And don't forget to copy crystal report '.rpt' file in debug and release folder
Run project and check the result here is output
Click Here to download Sample Crystal Report Project
No responses found. Be the first to comment...