-
Mar 24th, 2022, 02:51 AM
#1
Thread Starter
Lively Member
[RESOLVED] Cannot pass parameters to report
I have used this method many times with success, but all of a sudden its not working.
I have a report with two parameters.
I am trying to pass these two with the following code :
Code:
Me.PenalisasieTableAdapter.Fill(Me.LutzvilleDataSet.penalisasie)
Dim param1 As New ReportParameter("ReportParameterALIASNAAM", KiesVorm.CmbAliasnaam4.SelectedItem.ToString())
Dim param2 As New ReportParameter("ReportParameterPENALISASIE", KiesVorm.GepenaliseerComboBox.SelectedItem.ToString())
Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {param1, param2})
Me.ReportViewer1.Show()
Me.ReportViewer1.RefreshReport()
I get the following error : : 'Unable to cast object of type 'Microsoft.Reporting.WebForms.ReportParameter[]' to type 'System.Collections.Generic.IEnumerable`1[Microsoft.Reporting.WinForms.ReportParameter]'.'
I have searched in vain to get a solution. Please can someone help me, before I go mad.
Regards
-
Mar 24th, 2022, 12:26 PM
#2
Thread Starter
Lively Member
Re: Cannot pass parameters to report
Does anyone know if it it possible to filter a report's dataset with SQL rather than using the parameters in the report?
-
Mar 24th, 2022, 03:09 PM
#3
Re: Cannot pass parameters to report
I don't know about that, but I have spotted an issue in the error message that is easy to overlook:
Microsoft.Reporting.WebForms.ReportParameter
Microsoft.Reporting.WinForms.ReportParameter
It seems that somehow different assumptions are being made about whether you want the WebForms or WinForms variant... so specifying should solve it, eg:
Code:
Dim param1 As New Microsoft.Reporting.WinForms.ReportParameter("ReportParameterALIASNAAM", KiesVorm.CmbAliasnaam4.SelectedItem.ToString())
Dim param2 As New Microsoft.Reporting.WinForms.ReportParameter("ReportParameterPENALISASIE", KiesVorm.GepenaliseerComboBox.SelectedItem.ToString())
Me.ReportViewer1.LocalReport.SetParameters(New Microsoft.Reporting.WinForms.ReportParameter() {param1, param2})
(I've assumed WinForms, so change that to WebForms if apt)
-
Mar 24th, 2022, 03:23 PM
#4
Re: Cannot pass parameters to report
Good catch there... I'd be more inclined to believe the wrong namespace was imported... changing that might also fix the problem.
-tg
-
Mar 25th, 2022, 01:01 AM
#5
Thread Starter
Lively Member
Re: Cannot pass parameters to report
Thank you for spotting that Si.
It is as techgnome below suggested - I've imported the wrong namespace.
Regards
-
Mar 25th, 2022, 01:03 AM
#6
Thread Starter
Lively Member
Re: Cannot pass parameters to report
Thank you techgnome
I have indeed imported the wrong namespace:
Code:
''Imports Microsoft.Reporting.WebForms
Imports Microsoft.Reporting.WinForms
Regards
-
Feb 7th, 2023, 12:37 AM
#7
New Member
Re: [RESOLVED] Cannot pass parameters to report
Hi,I am Nany Swip
I have faced problems many times before which are very difficult for you to solve now. I have tried many times in the past with some code but could not find the exact solution if you know please tell me.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|