Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sub Reports not displaying records

Posted on 2008-10-13
3
Medium Priority
?
1,577 Views
Last Modified: 2011-10-03
hi all,

I have used sub reports to show some records in crystal reports. I have used dataset to fill records in crystal report. However, my main report is displaying the data but sub report is not able to display any data. I have used different datasets to fill data in sub reports as well as in main report.
I am not getting any error. Following is the code which I have to fill crystal report.


SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString.ToString());
    SqlDataAdapter adp;
    DataSet ds;
    SqlDataAdapter adp1;
    DataSet ds1;
    DataSet ds2;
    DataSet ds3;
    string cadNo;
    string qry;
 
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
          
            if (Request.QueryString["cadNo"] != null && Request.QueryString["cadNo"] != "")
            {
                
                cadNo = Request.QueryString["cadNo"].ToString().Trim();
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
 
                qry = "select " +
                "ch.cad_number, ch.flight_number, ch.flight_date, ch.origin, ch.destination, ch.origin + '/' + ch.destination as 'origin/destination', ch.currency_code, m.mawb_number, c.commercial_code as 'Account', c.name, cd.pieces as pieces,cd.weight as weight,cd.rate as rate,cd.amount as amount, ch.amount as 'Payable To Airline' " +
                "from cad_detail cd " +
                "left outer join mawb m on cd.mawb_id = m.mawb_id " +
                "inner join commercial c on c.commercial_id = m.payee_id " +
                "inner join cad_header ch on ch.cad_number = cd.cad_number "+
                "where cd.cad_number = '" + cadNo.ToString().Trim() + "'";
 
                ds = new DataSet();
                adp = new SqlDataAdapter(qry, con);
                adp.Fill(ds, "Main");
 
                qry = "select cec.charge_code, ec.charge_desc + ' (+)' as 'charge_desc', sum(cec.amount) as 'Add Amount', cec.plus_minus " +
                "from cad_extra_charge cec " +
                "inner join extra_charge ec on ec.charge_code = cec.charge_code " +
                "inner join cad_detail cd on cd.cad_detail_id = cec.cad_detail_id " +
                "where plus_minus = 'A' and cd.cad_number = '" + cadNo.ToString().Trim() + "' " +
                "group by cec.charge_code, charge_desc, plus_minus " +
                "order by Plus_minus ";
 
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
 
                ds1 = new DataSet();
                adp1 = new SqlDataAdapter(qry, con);
                adp1.Fill(ds1, "AddExtraCharge");
 
                qry = "select cec.charge_code, ec.charge_desc + ' (-)' as 'charge_desc', sum(cec.amount) as 'Less Amount', cec.plus_minus " +
                "from cad_extra_charge cec " +
                "inner join extra_charge ec on ec.charge_code = cec.charge_code " +
                "inner join cad_detail cd on cd.cad_detail_id = cec.cad_detail_id " +
                "where plus_minus = 'S' and cd.cad_number = '" + cadNo.ToString().Trim() + "' " +
                "group by cec.charge_code, charge_desc, plus_minus " +
                "order by Plus_minus ";
 
                ds2 = new DataSet();
                adp = new SqlDataAdapter(qry, con);
                adp.Fill(ds2, "LessExtraCharge");
 
                qry = "select mawb.mawb_id,mawb.mawb_number AS MAWBNo, ba.shipment_number as AWBNo, c.name, cd.weight, sum(cd.weight) as 'Total Weight' from cad_detail cd " +
                      "inner join mawb on mawb.mawb_id = cd.mawb_id " +
                      "inner join billing_awb ba on ba.mawb_id = mawb.mawb_id " +
                      "left outer join commercial c on ba.payee_id = c.commercial_id " +
                      "inner join products_services ps on ba.service = ps.service " +
                      "where cad_number = '" + cadNo.ToString().Trim() + "' " +
                      "and ps.product = 'DDC' " +
                      "group by mawb.mawb_id,mawb.mawb_number, ba.shipment_number, c.name, cd.weight ";
 
                ds3 = new DataSet();
                adp = new SqlDataAdapter(qry, con);
                adp.Fill(ds3, "RPXShipmentDetails");
 
                ReportDocument Origincopy = new ReportDocument();
                string Origin = (Server.MapPath("rptCadReport.rpt"));
                                
                Origincopy.Load(Origin);
                                Origincopy.Database.Tables["command"].SetDataSource(ds.Tables["Main"]);
                Origincopy.Subreports["subRptExtraCharges"].Database.Tables["command_0"].SetDataSource(ds1.Tables["AddExtraCharge"]);
                Origincopy.Subreports["subRptExtraCharges"].Database.Tables["command_1"].SetDataSource(ds2.Tables["LessExtraCharge"]);
                Origincopy.Subreports["subRptShipmentDetails"].Database.Tables["command_2"].SetDataSource(ds3.Tables["RPXShipmentDetails"]);
                CrystalReportViewer1.ReportSource = Origincopy;
                CrystalReportViewer1.DataBind();
 
              }
        }
        catch (Exception ex)
        {
            lblMessage.Text = ex.Message.ToString();
        }

Open in new window

0
Comment
Question by:Paramhans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 17

Expert Comment

by:MIKE
ID: 22796880
Check your LINKING...to the main report...
0
 
LVL 17

Accepted Solution

by:
MIKE earned 1500 total points
ID: 22796887
Also,...your sub should have its own connect strings....

0
 
LVL 17

Expert Comment

by:MIKE
ID: 22804315
Glad I could be of service...!

M
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question