locked
Crystal Report doesn't show data when generated RRS feed

  • Question

  • User971760330 posted

    Hi,

      When I generate it on runtime, it doesn't show any data. But it does when I check on the 'Main Report Preview' of VS 2010. I have also checked my stored procedure, it does produce data when I execute it. What seems to be the problem?

    This is my code in page_load:

    protected void Page_Load(object sender, EventArgs e)
            {
                string municipio = Request.QueryString["municipio"];
                string ano = Request.QueryString["ano"];
                string cnpj = Server.UrlDecode(Request.QueryString["cnpj"]);
    
                DataTable dt;
    
                string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
                
                using (SqlConnection cnn = new SqlConnection(CS))
                {
    
                    cnn.Open();
                    //stored procedure 
                    SqlCommand cmd = new SqlCommand("spConsultaRelatorioCompleto", cnn);
                    
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@ano", ano);
                        cmd.Parameters.AddWithValue("@municipio", municipio);
                        cmd.Parameters.AddWithValue("@cnpj", cnpj);
    
                        //read access to the database
                        SqlDataReader dr = cmd.ExecuteReader();
    
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        
                            //datatable with data
                            dt = new DataTable("dt");
                            
                            //datatable with datareader's data
                            dt.Load(dr);
                            da.Fill(dt);
                        
                    
                }
    
                ReportDocument MeuRelatorio = new ReportDocument();
                MeuRelatorio.Load(Server.MapPath("RelatorioConvenio.rpt"));
                MeuRelatorio.SetDataSource(dt);
                CrystalReportViewer1.ReportSource = MeuRelatorio;
    
                
    
    
            }
    
            
    
        }
    }

    I give some values in another webform when I click the button below:

    protected void btnExport_Click(object sender, EventArgs e)
            {
                Response.Redirect("RelatorioGerado.aspx?municipio=" + ddlmunicipioconvenente.Text + "&cnpj=" + Server.UrlEncode(tbcnpjconvenente.Text) + "&ano=" + tbAno.Text);
    
            }    

    Monday, January 12, 2015 10:39 AM

All replies