# Visual Basic > Reporting >  [RESOLVED] Cannot pass parameters to report

## GideonE

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 :



```
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

----------


## GideonE

Does anyone know if it it possible to filter a report's dataset with SQL rather than using the parameters in the report?

----------


## si_the_geek

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: 


```
        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)

----------


## techgnome

Good catch there... I'd be more inclined to believe the wrong namespace was imported... changing that might also fix the problem. 

-tg

----------


## GideonE

Thank you  for spotting that Si. 
It is as techgnome below suggested - I've imported the wrong namespace.

Regards

----------


## GideonE

Thank you techgnome

I have indeed imported the wrong namespace:



```
''Imports Microsoft.Reporting.WebForms
Imports Microsoft.Reporting.WinForms
```

Regards

----------

