I created a crystal report and webpage , I want to open crystal report in my webpage depends on the textbox value and i need when click the button i send the values to crystal reports to show my crystal report . I tried the following code , and I set the data source and connection to database :
protected void Button1_Click(object sender, EventArgs e)
{
rdoc.Load(Server.MapPath("~/RPT/RPT_CASH_RESULT.rpt"));
SqlCommand cmd = new SqlCommand("GET_ORDER_RESULT_PRINT_CASH", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ORDER_ID", TXTORDERID.Text);
cmd.Parameters.AddWithValue("@deptid", TXTDEPTID.Text);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
rdoc.SetDataSource(dt);
CrystalReportViewer1.ReportSource = rdoc;
CrystalReportViewer1.DataBind();
rdoc.SetDatabaseLogon("DBA", "1234");
}
}
when click the button its not showing the report only blank screen . what to do to show the report where is the mistake ?
I tried another solution but when click print button its not show the crystal report only blank page what to do i tried alot of solutions available in this site and other site ???
protected void BtnCrystal_Click(object sender, EventArgs e)
{
if (Session["patientno"] != null && Convert.ToInt32(Session["patientno"]) > 0)
{
ReportDocument reportDocument = new ReportDocument();
ParameterFields paramFields = new ParameterFields();
ParameterField paramField = new ParameterField();
ParameterField paramField1 = new ParameterField();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
ParameterDiscreteValue paramDiscreteValue1 = new ParameterDiscreteValue();
paramField.Name = "@ORDER_ID";
paramDiscreteValue.Value =Convert.ToInt32(TXTORDERID.Text);
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
paramField1.Name = "@deptid";
paramDiscreteValue1.Value =Convert.ToInt32(TXTDEPTID.Text);
paramField1.CurrentValues.Add(paramDiscreteValue1);
paramFields.Add(paramField1);
CrystalReportViewer1.ParameterFieldInfo = paramFields;
reportDocument.Load(Server.MapPath("~/RPT/RPT_CASH_RESULT.rpt"));
CrystalReportViewer1.ReportSource = reportDocument;
reportDocument.SetDatabaseLogon("DB", "1111","test","DB");
}