Dear all .Netters,
In my report, I have 3 parametes(Par1,Par2,Par3)
In this case, I only want to give parameter only for Par1,Par2.
I set Par3 as interal and hidden parameter.
In my webform, I write these code :

ReportViewer1.ProcessingMode = ProcessingMode.Local

Dim rep As LocalReport = ReportViewer1.LocalReport
rep.ReportPath = "RptProductPhoto.rdlc"

Dim I As Byte
Dim GetParameter As String = ""
Dim TotalParameter As Byte
TotalParameter = rep.GetParameters.Count
Dim par(TotalParameter - 1) As Microsoft.Reporting.WebForms.ReportParameter
For I = 0 To rep.GetParameters.Count - 1
GetParameter = rep.GetParameters.Item(I).Name
Select Case LCase(GetParameter)
Case "par1"
par(I) = New Microsoft.Reporting.WebForms.ReportParameter(GetParameter, "Par1")
Case "par2"
par(I) = New Microsoft.Reporting.WebForms.ReportParameter(GetParameter, "Par2")
End Select
Next
rep.SetParameters(par)
The program yields an error.
"Value cannot be null." reffering to "rep.SetParameters(par)" line code.

So, what should I do to remove the error ?

Thanks,

Kusno

make sure of the names of your parameters. like par1 is not Par1. you are pulling blank values. try that. otherwise if you are only calling two values from this entire form, just call those two fields directly. uses less coding and no loops. Plus, less room for error!

Why do I use loop ??
1. This form will be used by more than 1 reports.
2. Each reports will have different parameters.

"par1 is not Par1" is not a problem, because i only set lower case variable GetParameter.

Thanks

I am confused by your code.. but let's see.

You set par() equal to the total parameters, so if you have 3 parameters, it will be par(3). Are you trying to make this into an array for reading it later? Cause you are never adding the values to the array.

Try using this to add the values to the array:

ReportViewer1.ProcessingMode = ProcessingMode.Local

Dim rep As LocalReport = ReportViewer1.LocalReport
rep.ReportPath = "RptProductPhoto.rdlc"

Dim I As Byte
Dim GetParameter As String = ""
Dim TotalParameter As Byte
TotalParameter = rep.GetParameters.Count
Dim par(TotalParameter - 1) As Microsoft.Reporting.WebForms.ReportParameter
For I = 0 To rep.GetParameters.Count - 1
GetParameter = rep.GetParameters.Item(I).Name
Select Case LCase(GetParameter)
Case "par1"
par(I) = New Microsoft.Reporting.WebForms.ReportParameter(GetParameter, "Par1")
Case "par2"
par(I) = New Microsoft.Reporting.WebForms.ReportParameter(GetParameter, "Par2")
End Select
rep.SetParameters(par(I))
Next

This adds the certain parameter to your array of par. I was confused why you had it after the Next command and just (par) and not with a value.. so it makes sense now. Since you never added anything to "par", it returned null. Try that.

I've tried your code, but this was happened :

Unable to cast object of type 'Microsoft.Reporting.WebForms.ReportParameter' to type 'System.Collections.Generic.IEnumerable`1[Microsoft.Reporting.WebForms.ReportParameter]'.

I don't know why Reporting Services compels all parameters to be filled in, but in my experience when using Crystal Reports, we can pass to certain parameters that we want to.

But unfortunately, Crystal Reports that bundled in VS 2005 still has bug.

here, to find out what it is spitting out, try debugging the lines that are "null". If you can, make the string write out the par lines and see what it is displaying. Let me know.

Two things.. maybe on your first code it requires you to specifiy the visibibility, so replace these lines:
(GetParameter, "Par1", false/true)
(GetParameter, "Par2", false/true)
and make the false/true set to your visibility, false none, true visible.

The other, try this:

ReportViewer1.ProcessingMode = ProcessingMode.Local

Dim rep As LocalReport = ReportViewer1.LocalReport
rep.ReportPath = "RptProductPhoto.rdlc"

Dim I As Byte
Dim GetParameter As String = ""
Dim TotalParameter As Byte
TotalParameter = rep.GetParameters.Count
Dim paramlist As New Generic.List(Of ReportParameter)
For I = 0 To rep.GetParameters.Count - 1
GetParameter = rep.GetParameters.Item(I).Name
Select Case LCase(GetParameter)
Case "par1"
par.Add(New ReportParameter(GetParameter, "Par1"))
Case "par2"
par.Add(New ReportParameter(GetParameter, "Par2"))
End Select
Next
rep.SetParameters(par)
This article has been dead for over six months. Start a new discussion instead.