Advertisement

05.21.2008 at 09:25AM PDT, ID: 23421534
[x]
Attachment Details

Refresh report in reportviewer

Asked by DataconsultGent in Microsoft Visual Studio Express, Visual Studio .NET 2005, Visual Studio 2008

Tags: Microsoft, Visual Studio, 2005

I've created a report (.rdlc file). Then I've created a form on which I can choose some parameters to make a selection for the records in my report.  The first time I see the correct date but when I choose other parameters my report does not refresh.  I keep seeing the same data in my report.  Although I have "Me.reportviewer2.RefreshReport()" in my code.

Attached you can see my code
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
Sub Loadreport()
        Dim strSeason = CStr(CbxAantalJaar.SelectedItem)
        Dim strDistrict = CStr(CbxLaatsteJaar.SelectedItem)
        'declare connection string
        Dim cnString As String = "Data Source=aa;Initial Catalog=bb;User ID=cc;Password=dd"
        Dim conReport As SqlConnection = New SqlConnection(cnString)
        Dim cmdReport As SqlCommand = New SqlCommand()
        Dim drReport As SqlDataReader
        Dim dsReport As DataSet = New studentout()
        Try
            conReport.Open()
            cmdReport.CommandType = CommandType.Text
            cmdReport.Connection = conReport
            cmdReport.CommandText = "Select Nr, Season, District, NOM, Prenom From SEP_OUT_TA_EtudiantOut where Season='" & strSeason & "' and District = '" & strDistrict & "'"
            drReport = cmdReport.ExecuteReader()
            dsReport.Tables(0).Load(drReport)
            drReport.Close()
            conReport.Close()
            Me.ReportViewer2.LocalReport.ReportEmbeddedResource = "GSLijsten.Report1.rdlc"
 
            'prepare report data source
            Dim rds As ReportDataSource = New ReportDataSource()
            rds.Name = "studentout_SEP_OUT_TA_EtudiantOut"
            rds.Value = dsReport.Tables(0)
            Me.ReportViewer2.LocalReport.DataSources.Add(rds)
 
            'load report viewer
            Me.ReportViewer2.RefreshReport()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            'check if connection is still open then attempt to close it
            If conReport.State = ConnectionState.Open Then
                conReport.Close()
            End If
        End Try
    End Sub
[+][-]05.22.2008 at 05:37AM PDT, ID: 21623166

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 11:49AM PDT, ID: 21634720

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.26.2008 at 01:54AM PDT, ID: 21645361

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 08:23AM PDT, ID: 21701311

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Studio Express, Visual Studio .NET 2005, Visual Studio 2008
Tags: Microsoft, Visual Studio, 2005
Sign Up Now!
Solution Provided By: DataconsultGent
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628