Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 28687

Parameter name is defined multiple time(SSRS/VB.net)

$
0
0

I am creating a report interface to SSRS to get the report parameters and pass it to the report viewer to display the report. The issue I am having is my code works fine as long as the parameter is not a "multivalue parameter".  It will work with the muti value parameter as long as only one item is passed:

e.g This example works

Cust -text

sdate-date

enddate-date

Fieldtodisplay-multivalue (Test)

But if I try something like: this fails

Cust -text

sdate-date

enddate-date

Fieldtodisplay-multivalue (Test,test2)

The error I get is :

"a parameter with the name was defined multiple times"

Looking through the forums I realise that a multivalue parameter has to be passed as a string array. But I don't know how to get the other parameters as well as the multivalue parameter and send it to the paramlist function to display the report. Can anyone help me with this?

    Private Sub btnRpt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRpt.Click
        'Table
        Dim table1 As Table = DirectCast(ph_Param.FindControl("Ctrls_Table"), Table)
        Dim temp As String
        Dim temp1 As String
        Dim temp3() = New String() {}
        Dim i As Integer = 0
        Dim tbox As TextBox
        Dim radbox As Telerik.Web.UI.RadDatePicker
        Dim radDisplay As Telerik.Web.UI.RadComboBox
        Dim temp2 As String
        Dim x As Integer = 0
        Dim irsc As ReportCredential = New ReportCredential("Rept", "funday","http://testrpt/reportserver")

        rptViewer.ServerReport.ReportServerCredentials = irsc
        rptViewer.ServerReport.ReportServerUrl = New System.Uri("http://testrpt/reportserver")
        rptViewer.ServerReport.ReportPath = Request.QueryString("ReportID")


        ' Dim pInfo As ReportParameterInfoCollection,
        Dim paramList As New Generic.List(Of Microsoft.Reporting.WebForms.ReportParameter)
        'Dim param As New Microsoft.Reporting.WebForms.ReportParameter("pname", "pvalue", False)

        'Creating table/getting parameter name and value
        Try

            For Each tr As TableRow In table1.Rows
                For Each tc As TableCell In tr.Cells
                    For Each c As Control In tc.Controls
                        temp = ""
                        temp1 = ""
                        If c.[GetType]() Is GetType(TextBox) Then
                            tbox = DirectCast(c, TextBox)
                            temp = tbox.ID
                            temp1 = tbox.Text
                            'param.Name = tbox.ID
                            'param.Values.Add(tbox.Text)
                            'paramList.Add(param)
                        ElseIf c.[GetType]() Is GetType(Telerik.Web.UI.RadDatePicker) Then
                            radbox = DirectCast(c, Telerik.Web.UI.RadDatePicker)
                            temp = radbox.ID
                            temp1 = radbox.SelectedDate.Value
                            'param.Name = radbox.ID
                            'param.Values.Add(radbox.SelectedDate.Value)
                            'paramList.Add(param)
                        ElseIf c.[GetType]() Is GetType(Telerik.Web.UI.RadComboBox) Then
                            radDisplay = DirectCast(c, Telerik.Web.UI.RadComboBox)
                            Try
                                temp = radDisplay.ID
                                'param.Name = radDisplay.ID
                                'Dim chktext As Integer
                                'chktext = radDisplay.CheckedItems.Count
                                'Dim test1(chktext) As String
                                For Each item In radDisplay.CheckedItems

                                    temp1 = item.Text
                                    temp1 = temp1 + ", " + temp2
                                    temp1 = temp1 + temp2

                                Next
                                'For s = 0 To radDisplay.CheckedItems.Count - 1
                                '    test1(s) = radDisplay.CheckedItems.Item(s).Text
                                'Next

                                temp1 = temp1.Remove(0, 1)
                                'param.Values.AddRange(test1)
                                'paramList.Add(param)
                            Catch ex As Exception
                                MsgBox(ex.Message)
                            End Try


                        End If
                        If c.[GetType]() IsNot GetType(Label) And c.[GetType]() IsNot GetType(Telerik.Web.UI.RadComboBox) Then
                            'paramList.Add(param)
                            paramList.Add(New Microsoft.Reporting.WebForms.ReportParameter(temp, temp1.Trim, False))

                        End If

                    Next
                Next
            Next

            rptViewer.ProcessingMode = ProcessingMode.Remote
            rptViewer.ServerReport.SetParameters(paramList)
            rptViewer.ServerReport.Refresh()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub



RJ






Viewing all articles
Browse latest Browse all 28687


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>