Dear Friends ,
Please help me in displaying data from database into the crystal report .
I have attached the complete code as a zip file
index.aspx
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.Configuration;
- using System.Data;
- using System.Data.SqlClient;
- using System.IO;
- using CrystalDecisions.CrystalReports.Engine;
- using CrystalDecisions.ReportSource;
- using CrystalDecisions.Reporting;
- using CrystalDecisions.Shared;
- public partial class index : System.Web.UI.Page
- {
- SqlConnection con = new SqlConnection(Class1.dbConnectionString);
- SqlDataAdapter adap;
- DataSet ds;
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- con.Open();
- SqlCommand cmd = new SqlCommand("BANKPROCEDURE", con);
- cmd.CommandType = CommandType.StoredProcedure;
- SqlDataAdapter da = new SqlDataAdapter(cmd);
-
- DataTable ds = new DataTable();
- ds.TableName = "BankDataSet1";
- da.Fill(ds);
-
-
- ReportDocument rdoc = new ReportDocument();
- rdoc.Load(Server.MapPath("BankCrystalReport.rpt"));
- rdoc.SetDataSource(ds);
- rdoc.SetParameterValue("CODE", Convert.ToInt32 ( DropDownList1.Text));
- CrystalReportViewer1.ReportSource = rdoc;
- CrystalReportViewer1.RefreshReport();
- CrystalReportViewer1.DataBind();
- con.Close();
- }
- }
dbo.BANKPROCEDURE
- ALTER PROCEDURE dbo.BANKPROCEDURE
- AS
- SELECT * FROM BANK
- RETURN