none
Report Viewer does not update-refresh data... RRS feed

  • General discussion

  • I have a windows application that allows the user to Insert Update and Delete lets say Customers and Customers-Orders. I added the report viewer control and it works just fine the first time. The first time I call the report from the form the report data is accurate and correct. Here is the issue, If I close the report and go back to the form to Insert, Update or Delete data and then call the report again, the report data is the same as the first time I called it. If I close the application>run it again>call the report then the report display the correct (Updated) data. I think it has something to do with the dataset not being updated or something like that. 
    Any help would be greatly appreciated.

    My application is coded on C# using MSSQL Server.

    Friday, September 24, 2010 3:33 PM

All replies

  • Hi JCMartinez,

    In your report generation method write code to refresh reportviewer and report.

    this

     

    .reportViewer1.RefreshReport();

     

    this.reportViewer1.Refresh();

    By writing these two line check it out again.

     

     

    Saturday, September 25, 2010 11:07 AM
  • Thanks for the reply.

     

    I tried the two lines you above, but is still the same. Here is my code before and after the 2 lines above. Again any help would be appreciated.

     

    Before:

    public partial class frmReportPolicies : Form

        {

            public frmReportPolicies()

            {

                InitializeComponent();

            }

     

            private void frmReport_Load(object sender, EventArgs e)

            {                

            }

     

            private void btnGenerate_Click(object sender, EventArgs e)

            {

                // TODO: This line of code loads data into the 'dsReport.tblPolicies' table. You can move, or remove it, as needed.

                this.tblPoliciesTableAdapter.Fill(this.dsReport.tblPolicies,dateTimePicker1.Text, dateTimePicker2.Text);

                this.reportViewer1.RefreshReport();

     

            }

     

            private void frmReport_FormClosing(object sender, FormClosingEventArgs e)

            {

                reportViewer1.LocalReport.ReleaseSandboxAppDomain();

            }

     

            private void reportViewer1_ReportRefresh(object sender, CancelEventArgs e)

            {  

            }

        }

     

     

    After

    public partial class frmReportPolicies : Form

        {

            public frmReportPolicies()

            {

                InitializeComponent();

            }


            private void frmReport_Load(object sender, EventArgs e)

            {

                     

            }


            private void btnGenerate_Click(object sender, EventArgs e)

            {

                this.reportViewer1.RefreshReport(); //Line 1

                this.reportViewer1.Refresh();  

    //Line 2



     

     

                // TODO: This line of code loads data into the 'dsReport.tblPolicies' table. You can move, or remove it, as needed.

                

    this.tblPoliciesTableAdapter.Fill(this.dsReport.tblPolicies,dateTimePicker1.Text, dateTimePicker2.Text);

                

    this.reportViewer1.RefreshReport();

                

            }


            private void frmReport_FormClosing(object sender, FormClosingEventArgs e)

            {

                reportViewer1.LocalReport.ReleaseSandboxAppDomain();

            }


            private void reportViewer1_ReportRefresh(object sender, CancelEventArgs e)

            {

            }

        }

    Saturday, September 25, 2010 1:46 PM