in my practicle i want to print selected record by id or gr name but its not wokring report showing all records not seletcted where is mistakes kindly suggest me right code.
- protected void btnPrint_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(@"Connection string");
- con.Open();
- SqlCommand cmd = new SqlCommand("Select * from student_details Where grno Like'" + TextBox1.Text + "' or name like'"+ studentname +"%'",con);
- SqlDataAdapter sda = new SqlDataAdapter(cmd);
- DataSet ds = new DataSet();
- sda.Fill(ds);
-
- ReportDocument crReport = new ReportDocument();
- crReport.Load(Server.MapPath("~/StudentsRecord.rpt"));
- crReport.SetDataSource(ds.Tables["student_details"]);
-
- CrystalReportViewer1.ReportSource = crReport;
-
- crReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat,Response, false, "Student Records");
- con.Close();
- }