Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
C#
protected void Button1_Click(object sender, EventArgs e)
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("sp_RptRouteWiseNetSaleDetails", con);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        CrystalReportViewer1.RefreshReport();
        ReportDocument rpdoc = new ReportDocument();
        rpdoc.Load(Server.MapPath("RouteWiseNetSaleDetailsByDate.rpt"));
        rpdoc.SetDataSource(dt);
        rpdoc.SetParameterValue("@intFlag", TextBox1.Text);
        rpdoc.SetParameterValue("@Code", Convert.ToString(TextBox2.Text));
        rpdoc.SetParameterValue("@dtpFrom", Convert.ToDateTime(TextBox3.Text).ToShortDateString());
        rpdoc.SetParameterValue("@dtpTo", Convert.ToDateTime(TextBox4.Text).ToShortDateString());
        CrystalReportViewer1.RefreshReport();
        CrystalReportViewer1.ReportSource = rpdoc;
        CrystalReportViewer1.DataBind();
        con.Close();




    }
Posted
Comments
Joan Magnet 1-Apr-15 5:59am    
Ask to your DBA, this SQL procedure is from your database.
axeemg 2-Apr-15 6:22am    
i have access to Database second yes this procedure from database

1 solution

This is likely because TextBox1.Text is blank.
 
Share this answer
 
Comments
axeemg 2-Apr-15 6:24am    
TextBox1.Text filling by value and i also tried like this:
rpdoc.SetParameterValue("@intFlag", "ABC"); or
rpdoc.SetParameterValue("@intFlag", ABC);
ZurdoDev 2-Apr-15 7:27am    
You did rpdoc.SetParameterValue("@intFlag", "ABC") and still got the error that @intFlag was not set?

Oh, I see it's likely because you're calling RefreshReport. Try taking that line out.
axeemg 4-Apr-15 7:07am    
Dear i already did this but getting same exception.

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