0
votes

I am building a Crystal Report in Visual Studio 2010 using C#. My report must contain a sub-report. When I run my report individually it works perfectly, but when I add sub-report I immediately get the dialog window saying "The report you requested requires further information" I can only type in name and password, database name field is read only. When I enter the information it loads for a few seconds and then reappears again enter image description here

My original report and sub-report are using different stored procedures that are put into one DataSet enter image description here each report is connected to its own stored procedure. When I run only main report it runs fine, but when the sub-report is added the diaglog reappears.

I am connecting page to the report like this, I hard code all the fields for now, and the sub-report is linked to the main report with facility_id

 SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["chartsdbnewConnectionString"].ConnectionString);
    ReportDocument rdoc = new ReportDocument();
    cn.Open();
    SqlCommand cmd = new SqlCommand("RIV_RPT_CENSUS_ASOFDATE_copy_jenny", cn);
    cmd.CommandType = CommandType.StoredProcedure;

    cmd.Parameters.AddWithValue("@facility_search_ind", 0);
    cmd.Parameters.AddWithValue("@facility_id_from", 50);
    cmd.Parameters.AddWithValue("@facility_id_to", 50);
    cmd.Parameters.AddWithValue("@facility_name_from", ' ');
    cmd.Parameters.AddWithValue("@facility_name_to", "zz");
    cmd.Parameters.AddWithValue("@Resident_search_ind", 1);
    cmd.Parameters.AddWithValue("@Resident_id_from", 0);
    cmd.Parameters.AddWithValue("@Resident_id_to", 0);
    cmd.Parameters.AddWithValue("@Resident_name_from", "A");
    cmd.Parameters.AddWithValue("@Resident_name_to", "ZZZZ");
    cmd.Parameters.AddWithValue("@AsOfDate", "2016-01-27");
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataTable ds = new DataTable();
    da.Fill(ds);
    rdoc.Load(Server.MapPath("CrystalReport.rpt"));
    rdoc.SetDataSource(ds);
    Session["ReportDocument"] = rdoc;
    crs1.ReportSource = (ReportDocument)Session["ReportDocument"];



    crs1.DataBind();
    cn.Close();

I spent a lot of time googling this issue but none of the solutions online worked. I feel that I connect my sub-report not in the correct way. I still very new to the Crystal Report technology. Please help, its my 3rd day slaving on it.

1

1 Answers

1
votes

You need to give the subreport a datasource in your code behind as well. Something like:

rdoc.OpenSubreport("my_awesome_subreport.rpt").SetDataSource(ds);