Index was out of range - ReportViewer bug for BindingSource.Filter
-
Mittwoch, 7. März 2012 14:16
Based on Brian's blog: http://blogs.msdn.com/b/brianhartman/archive/2009/01/22/why-is-reportviewer-ignoring-bindingsource-operations.aspx
and help from http://social.msdn.microsoft.com/forums/en-us/vsreportcontrols/thread/E91949C1-5426-4796-9157-732F96466EA4 - Aug1Sg for VB conversion
Here's the code I have:
QryBindingSource.Filter = FilterStr
Dim tempBindingSource As New BindingSource(QryBindingSource, "")
Me.ReportViewer1.LocalReport.DataSources(0).Value = tempBindingSourceBut it errors out to Index was out of range.
rest of the code after above lines:
Me.ReportViewer1.LocalReport.ReportPath = "\reports\report2.rdlc"
rows=QryTableAdapter.FillByDate(PharmDataSet.qry, gblVariables.StartDate, gblVariables.EndDate)
if rows > 0 then
Me.ReportViewer1.RefreshReport()
Else
MsgBox ("Sorry, no Data available", MsgBoxStyle.OkOnly)
Me.Close()
End If
Please help.
Thanks
PS: Using VB 2005
- Bearbeitet Mr.Kris Mittwoch, 7. März 2012 14:17
Alle Antworten
-
Mittwoch, 7. März 2012 15:07
Here's how I modified the code to work using info from 'UV protector': http://social.msdn.microsoft.com/forums/en-us/vsreportcontrols/thread/392FCDFC-7724-49C9-8AFA-7CAD84E5EEAA
QryBindingSource.Filter = FilterStr
If QryBindingSource.Count = 0 then
rows =0
Else
Dim filteredTable as DataTable
Dim currDataRowView as DataRowView
currDataRowView = QryBindingSource.Current
filteredTable = currDataRowView.DataView.ToTable
Me.ReportViewer1.LocalReport.ReportPath = "\reports\report2.rdlc"
Me.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("PharmDataSet_qry", filteredTable))
rows=QryTableAdapter.FillByDate(PharmDataSet.qry, gblVariables.StartDate, gblVariables.EndDate)
End If
if rows > 0 then
Me.ReportViewer1.RefreshReport()
Else
MsgBox ("Sorry, no Data available", MsgBoxStyle.OkOnly)
Me.Close()
End If
But curious as why initial code errors?
Thanks
- Bearbeitet Mr.Kris Mittwoch, 7. März 2012 15:25 filtered row count

