Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
Hi..
I need to display report using crystal reports, i'm new to net,so please help me
I tried something but, when i'm running my code it's displaying nothing.

What I have tried:

ReportDocument reportdocument = new ReportDocument();
       reportdocument.Load(Server.MapPath("~/CrystalReport2.rpt"));

       DataSet1 dsPersonInfo = new DataSet1();
       SqlConnection con = new SqlConnection("Data Source=localhost;user id=sa; password=sa;Initial Catalog=test;");

       con.Open();

       SqlCommand cmd = new SqlCommand("select * from PersonInfo", con);
       SqlDataAdapter da = new SqlDataAdapter(cmd);
       da.Fill(dsPersonInfo, "PersonInfo");
       con.Close();



       reportdocument.SetDataSource(dsPersonInfo);
       CrystalReportViewer1.ReportSource = reportdocument;

       CrystalReportViewer1.DataBind();


PersonInfo
is Dataset DataTable Name


Thanks
Posted
Updated 23-Jan-17 0:32am
Comments
Afzaal Ahmad Zeeshan 23-Jan-17 5:50am    
There are already quite a lot of easy to use samples and examples on this topic; try one of them.

1 solution

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900