Shalini rajendran

Shalini rajendran

  • NA
  • 21
  • 10.5k

Display bulk of records as table format in Crystal Report

Dec 7 2015 1:52 AM

Hi Everyone,

I would like to display application form as tabular format for that am using crystal report viewer..Here my issue is in my table I have bulk of data's but when i run my application it shows only 1st row of the table..I would like to display all the records which are present in table..

Here am using C# winforms,visual studio 2010,sql server 2008..

Here is my code & sample Result set:
private void Report_Load(object sender, EventArgs e) 
{
ReportDocument crystalreport = new ReportDocument();
crystalreport
.Load(@"D:\Development\VS2010 Projects\MVC Applications\Application_Print_CrystalReports\Application_Print_CrystalReports\leavereport.rpt");
//Here am writing query to display all the records which are present in the table
Customers dscustomers = GetData("Select * From Leave_Form");
crystalreport
.SetDataSource(dscustomers);
crystalReportViewer1
.ReportSource = crystalreport;
crystalReportViewer1
.Refresh();
crystalReportViewer1
.Dock = DockStyle.Fill; this.Controls.Add(crystalReportViewer1);
}
//Here customers is my dataset name
private Customers GetData(string query)
{
string conString = ConfigurationManager.ConnectionStrings["Myconn"].ConnectionString;
SqlCommand cmd = new SqlCommand(query); using (SqlConnection con = new SqlConnection(conString))
{ using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd
.Connection = con;
con
.Open();
sda
.SelectCommand = cmd; using (Customers dscustomers = new Customers())
{
sda
.Fill(dscustomers, "DataTable1"); return dscustomers;
}
}
} 



Answers (1)