Click here to Skip to main content
15,900,716 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
Hi all

Below is mycode for displaying the report

VB
Dim dt As New DataTable

       dt.Rows.Clear()

       Dim cmd As New SqlCommand("Select ProductCode,sum(price) as price, DateTransaction from sales where ProductCode= '" & ComboBox1.SelectedValue.ToString & "' group BY ProductCode, DateTransaction", con)
       con.Close()
       con.Open()

       Dim da As New SqlDataAdapter(cmd)
       da.Fill(dt)

       Dim reportDataSource As New ReportDataSource()
       reportDataSource.Name = "DataSet1"
       reportDataSource.Value = dt
       _reportViewer.LocalReport.ReportPath = "\Report2.rdlc"
       _reportViewer.LocalReport.DataSources.Add(reportDataSource)
       _reportViewer.RefreshReport()


The problem is from the combo box which ever value i selects first, of all other values, it's showing the same data.

e.g. if i am selecting P002, it will display
then when select P001 or P003, at that time also it's displaying the data of P002.

PLease tell me what is went wrong in this..
Posted

1 solution

Add these lines in your code & try again
VB
ReportViewer1.Reset()
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.Refresh()

Updated code should be like below
VB
Dim reportDataSource As New ReportDataSource()
reportDataSource.Name = "DataSet1"
reportDataSource.Value = dt
_reportViewer.Reset()
_reportViewer.LocalReport.ReportPath = "\Report2.rdlc"
_reportViewer.LocalReport.DataSources.Clear()
_reportViewer.LocalReport.DataSources.Add(reportDataSource)
_reportViewer.LocalReport.DataSources.Refresh()
_reportViewer.RefreshReport()
 
Share this answer
 
Comments
[no name] 9-Dec-13 5:59am    
Yeah it worked..Thanks thatraja..:)
thatraja 9-Dec-13 7:23am    
:D It's a medical miracle! In past I have faced similar issue in Crystal reports & applied these(similar code) & worked. Welcome
[no name] 9-Dec-13 7:57am    
:D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900