locked
C# 2005 Winform LocalReport Drillthrough is blank RRS feed

  • Question

  • Hi there

    I am creating a WinApp using C# 2005. I am at a loss regarding the drillthrough report. It is blank, I suspect that it may have something to do with the parameter. Everything else works fine

    Below is some of my code:
            private void rptExposures_Load(object sender, EventArgs e)
            {
                try
                {
                    // TODO: These lines of code loads data into the 'PortManDataSet.rptExposure' table. 
                    // You can move, or remove it, as needed.
                    this.PortManDataSet.EnforceConstraints = false;
                    if (Imp_Exp == "Import")
                    {
                        if (DivID == 0)
                            this.rptExposureTableAdapter.FillByAccDate(this.PortManDataSet.rptExposure, AccID,
                                FP_Code, "I", S_Date, E_Date);
                        else
                            this.rptExposureTableAdapter.FillByDivDate(this.PortManDataSet.rptExposure, AccID, DivID,
                                FP_Code, "I", S_Date, E_Date);
                    }
                    else if (Imp_Exp == "Export")
                    {
                        if (DivID == 0)
                            this.rptExposureTableAdapter.FillByAccDate(this.PortManDataSet.rptExposure, AccID,
                                FP_Code, "E", S_Date, E_Date);
                        else
                            this.rptExposureTableAdapter.FillByDivDate(this.PortManDataSet.rptExposure, AccID, DivID,
                                FP_Code, "E", S_Date, E_Date);
                    }
    
                    S_Year = S_Date.ToString().Substring(0, 4);
                    S_Month = S_Date.ToString().Substring(5, 2);
    
                    E_Year = E_Date.ToString().Substring(0, 4);
                    E_Month = E_Date.ToString().Substring(5, 2);
    
                    this.rvExposuresMT.LocalReport.SetParameters
                        (new ReportParameter[]
                        {
                            new ReportParameter("parImpExp", Imp_Exp),
                            new ReportParameter("parDivID", DivID.ToString()),
                            new ReportParameter("parS_Year", S_Year),
                            new ReportParameter("parS_Month", S_Month),
                            new ReportParameter("parE_Year", E_Year),
                            new ReportParameter("parE_Month", E_Month)
                        }
                        );
    
                    // Add handler for drillthrough
                    this.rvExposuresMT.Drillthrough += new DrillthroughEventHandler(rvExposuresMT_Drillthrough);
    
                    this.rvExposuresMT.RefreshReport();
                }
    
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "An Error has occured", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
    
            private void rvExposuresMT_Drillthrough(object sender, DrillthroughEventArgs e)
            {
                try
                {
                    LocalReport localReport = (LocalReport)e.Report;
                    localReport.DataSources.Add(new ReportDataSource("dsPortMan_Exposures", ExposuresBindingSource));
                    ReportParameterInfoCollection DrillThroughValue = e.Report.GetParameters();
                    ExpNo = DrillThroughValue.ToString();
    
                    // TODO: This line of code loads data into the 'PortManDataSet.Exposures' table. 
                    // You can move, or remove it, as needed.
                    this.ExposuresTableAdapter.FillByExpNo(this.PortManDataSet.Exposures, ExpNo);
    
                }
    
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "An Error has occured", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
    
    Your guidance and help will be appreciated.
    It's not the blowing of the wind that determines your destination, it's the set of the sail. J Rohn
    Tuesday, May 19, 2009 1:18 PM

All replies

  • I have made the following changes:

            private void rptExposures_Load(object sender, EventArgs e)
            {
                try
                {
                    // TODO: These lines of code loads data into the 'PortManDataSet.rptExposure' table. 
                    // You can move, or remove it, as needed.
                    this.PortManDataSet.EnforceConstraints = false;
                    if (Imp_Exp == "Import")
                    {
                        if (DivID == 0)
                            this.rptExposureTableAdapter.FillByAccDate(this.PortManDataSet.rptExposure, AccID,
                                FP_Code, "I", S_Date, E_Date);
                        else
                            this.rptExposureTableAdapter.FillByDivDate(this.PortManDataSet.rptExposure, AccID, DivID,
                                FP_Code, "I", S_Date, E_Date);
                    }
                    else if (Imp_Exp == "Export")
                    {
                        if (DivID == 0)
                            this.rptExposureTableAdapter.FillByAccDate(this.PortManDataSet.rptExposure, AccID,
                                FP_Code, "E", S_Date, E_Date);
                        else
                            this.rptExposureTableAdapter.FillByDivDate(this.PortManDataSet.rptExposure, AccID, DivID,
                                FP_Code, "E", S_Date, E_Date);
                    }
    
                    S_Year = S_Date.ToString().Substring(0, 4);
                    S_Month = S_Date.ToString().Substring(5, 2);
    
                    E_Year = E_Date.ToString().Substring(0, 4);
                    E_Month = E_Date.ToString().Substring(5, 2);
    
                    this.rvExposuresMT.LocalReport.SetParameters
                        (new ReportParameter[]
                        {
                            new ReportParameter("parImpExp", Imp_Exp),
                            new ReportParameter("parDivID", DivID.ToString()),
                            new ReportParameter("parS_Year", S_Year),
                            new ReportParameter("parS_Month", S_Month),
                            new ReportParameter("parE_Year", E_Year),
                            new ReportParameter("parE_Month", E_Month)
                        }
                        );
    
                    // Add handler for drillthrough
                    this.rvExposuresMT.Drillthrough += new DrillthroughEventHandler(rvExposuresMT_Drillthrough);
    
                    this.rvExposuresMT.RefreshReport();
                }
    
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "An Error has occured", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
    

            private void rvExposuresMT_Drillthrough(object sender, DrillthroughEventArgs e)
            {
                try
                {
                    LocalReport localReport = (LocalReport)e.Report;
                    localReport.DataSources.Add(new ReportDataSource("dsPortMan_ExposureHistory", ExposureHistoryBindingSource));
                    ReportParameterInfoCollection DrillThroughValue = e.Report.GetParameters();
                    ExpNo = DrillThroughValue.ToString();
    
                    // TODO: This line of code loads data into the 'PortManDataSet.ExposureHistory' table. 
                    // You can move, or remove it, as needed.
                    this.ExposureHistoryTableAdapter.Fill(this.PortManDataSet.ExposureHistory, ExpNo);
    
                }
    
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "An Error has occured", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
    

    How do I get my Report Paramter through to my SQL Query Parameter?

    Thanx


    It's not the blowing of the wind that determines your destination, it's the set of the sail. J Rohn
    Wednesday, May 20, 2009 12:05 PM
  • I believe my problem is wthin these statements within the Drillhtrough event:

                    ReportParameterInfoCollection DrillThroughValue = e.Report.GetParameters();
                    ExpNo = DrillThroughValue.ToString();
    ExpNo is s string which I use as a parameter to my query. What is the correct way of assigning the value of the DrillThroughValue to ExpNo. There will always be only one value within DrillThroughValue.

    I am desperate for help.

    Thanx
    It's not the blowing of the wind that determines your destination, it's the set of the sail. J Rohn
    Friday, May 22, 2009 6:24 AM
  • I am desperate for help.

    Please, what am I doing wrong. I have checked the parameter pulls through correctly, yet my report is still blank.

            private void rvExposuresMT_Drillthrough(object sender, DrillthroughEventArgs e)
            {
                try
                {
                    LocalReport localReport = (LocalReport)e.Report;
                    ReportParameterInfoCollection DrillThroughValue = e.Report.GetParameters();
    
                    foreach (ReportParameterInfo d in DrillThroughValue)
                    {
                        ExpNo = d.Values[0].ToString().Trim();
                    }
    
                    localReport.DataSources.Add(new ReportDataSource("dsPortMan_ExposureHistory", ExposureHistoryBindingSource));
    
                    // Temp BindingSource for DrillThrough report
                    BindingSource tempBindingSource = new BindingSource(this.ExposureHistoryBindingSource, "");
                    this.rvExposuresMT.LocalReport.DataSources[1].Value = tempBindingSource;
    
                    // TODO: This line of code loads data into the 'PortManDataSet.Exposures' table. 
                    // You can move, or remove it, as needed.
                    this.ExposureHistoryTableAdapter.Fill(this.PortManDataSet.ExposureHistory, ExpNo);
    
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "An Error has occured", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
    

    It's not the blowing of the wind that determines your destination, it's the set of the sail. J Rohn
    Monday, May 25, 2009 11:16 AM
  • ReportParameterInfoCollection has the following variables in an array.
    ("parImpExp"),("parDivID"), ("parS_Year"), ("parS_Month"), ("parE_Year"), ("parE_Month")

    If you can add if condition to check d.Name == "parImpExp" and then assign ExpNo to d.Values.ToString().Trim(); it may fix your issue. My doubt is, what is ExpNo value at the end of each for loop ? If I understand correctly, it will have parE_Month value. This is not what you want to send the ExposureHistoryTableAdapter. Please try.
    Regards
    Chandra

    Tuesday, May 26, 2009 2:12 PM