Can pass values as parameters except for a string value? Why Not?
Hi, :confused:
I am having difficulty trying to pass a string variable parameter to the reportviewer. See code below.... I can pass variables p and q just fine, but s gives me the error "Value of type 'Microsoft.Reporting.WinForms.ReportParameter' cannot be converted to type String". I had checked the report to make sure that the parameter type is of type 'String' which it is. Any ideas?
Thanks
Eric
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
Dim p As Microsoft.Reporting.WinForms.ReportParameter
Dim q As Microsoft.Reporting.WinForms.ReportParameter
Dim s As Microsoft.Reporting.WinForms.ReportParameter
If (btnAll.Checked = True) Then
Dim params(1) As Microsoft.Reporting.WinForms.ReportParameter
p = New Microsoft.Reporting.WinForms.ReportParameter("from", dteFrom.Value)
q = New Microsoft.Reporting.WinForms.ReportParameter("to", dteTo.Value)
params(0) = p
params(1) = q
ReportViewer1.LocalReport.SetParameters(params)
DataTable1TableAdapter.Fill(DataSet1.DataTable1, dteFrom.Value, dteTo.Value)
ReportViewer1.RefreshReport()
Else
Dim params(2) As Microsoft.Reporting.WinForms.ReportParameter
p = New Microsoft.Reporting.WinForms.ReportParameter("from", dteFrom.Value)
q = New Microsoft.Reporting.WinForms.ReportParameter("to", dteTo.Value)
If (btnMitch.Checked = True) Then
s = New Microsoft.Reporting.WinForms.ReportParameter("atty", "Mitch")
End If
If (btnMarc.Checked = True) Then
s = New Microsoft.Reporting.WinForms.ReportParameter("atty", "Marc")
End If
If (btnWayne.Checked = True) Then
s = New Microsoft.Reporting.WinForms.ReportParameter("atty", "Wayne")
End If
If (btnMark.Checked = True) Then
s = New Microsoft.Reporting.WinForms.ReportParameter("atty", "Mark")
End If
params(0) = p
params(1) = q
params(2) = s
ReportViewer1.LocalReport.SetParameters(params)
DataTable1TableAdapter.FillBy(DataSet1.DataTable1, dteFrom.Value, dteTo.Value, s)
ReportViewer1.RefreshReport()
End If
End Sub
Re: Can pass values as parameters except for a string value? Why Not?
Which statement is causing the error? This one looks incorrect
DataTable1TableAdapter.FillBy(DataSet1.DataTable1, dteFrom.Value, dteTo.Value, s)
because arguments 2 and 3 appear to be date variables. Argument 4 is the report parameter object. Should it be a string variable?
Re: Can pass values as parameters except for a string value? Why Not?
The statement you had copied and pasted. The error shows a squiggly on the "s" where the error occurs on.
thanks
eric
Quote:
Originally Posted by brucevde
Which statement is causing the error? This one looks incorrect
DataTable1TableAdapter.FillBy(DataSet1.DataTable1, dteFrom.Value, dteTo.Value, s)
because arguments 2 and 3 appear to be date variables. Argument 4 is the report parameter object. Should it be a string variable?