locked
Multiple Parameters giving Object must implement IConvertible error RRS feed

  • Question

  • User-1542511547 posted

    I have the attached code.  If I run the report with single parameter (and comment out the two multiple parameter rows), the report runs great.

    If I reverse (comment out single and uncomment multiple), the report fails with an error Object must implement IConvertible and highlights the row Search(0) = New SqlParameter("@loc", cboLoc.text)

    Been reading a little about the error and it appears that it may be that I need to designate the type of parameter to SQL.  Can I designate the SQL type in this code or do I need to re-write it another way?

        Protected Sub cmdRun_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdRun.Click
            rvmySample.Visible = True
            Dim thisConnection As New SqlConnection(thisConnectionString)
            Dim thisDataSet As New System.Data.DataSet()
    
            '******************************************************************************************************
            '*****Single Parameter
            'thisDataSet = SqlHelper.ExecuteDataset(thisConnection, "spAvgDailyPatients", cboLoc.Text)
            '*****Multiple Parameter 
            SearchValue(0) = New SqlParameter("@Loc", cboLoc.Text)
            thisDataSet = SqlHelper.ExecuteDataset(thisConnection, "spAvgDailyPatients", SearchValue)
            '******************************************************************************************************
    
            Dim datasource As New ReportDataSource("qryAvgDailyPat_rptAvgDailyPatients", thisDataSet.Tables(0))
    
            rvmySample.LocalReport.DataSources.Clear()
            rvmySample.LocalReport.DataSources.Add(datasource)
    
            If thisDataSet.Tables(0).Rows.Count = 0 Then
                lblMessage.Text = "Sorry, no locations available!"
            End If
    
            rvmySample.LocalReport.Refresh()
    
        End Sub
    Monday, March 12, 2012 11:12 AM

Answers

  • User-1542511547 posted

    Found a way to use multiple parameters for the report without the code above.

    Right clicked the Datasource in Split view, selected properties, and went to Select Parameters.  I put one for each parameter and used QueryStrings.  Worked great.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 23, 2012 3:39 PM