How do I pass multiple discrete values to a ReportDocument using SetParameterValue()?

D

dan_williams

Is it possible to pass multiple discrete values to a report document so
that I can export it to PDF?

I've managed to perform the following code to display a Crystal Report
Viewer ok, but i want to be able to export that to a PDF and print it.

Dim invNos As New ArrayList -- populated elsewhere in my code.
Dim oRpt As New ReportDocument
oRpt.Load(MapPath(<crystalReport>))

Dim crParameterFields As ParameterFields
Dim crParameterField As ParameterField
Dim crParameterValues As ParameterValues
Dim crParameterDiscreteValue As ParameterDiscreteValue

CrystalReportViewer1.ReportSource = oRpt
crParameterFields = CrystalReportViewer1.ParameterFieldInfo
crParameterField = crParameterFields.Item("InvNos")
crParameterValues = crParameterField.CurrentValues

For i = 0 To invNos.Count - 1
crParameterDiscreteValue = New ParameterDiscreteValue
crParameterDiscreteValue.Value = invNos(i)
crParameterValues.Add(crParameterDiscreteValue)
crParameterDiscreteValue = Nothing
Next

CrystalReportViewer1.ParameterFieldInfo = crParameterFields

-- The code below errors as I haven't managed to pass my
-- InvNos parameter to my ReportDocument.

Dim st As System.IO.Stream
st = oRpt.ExportToStream
CrystalDecisions.Shared].ExportFormatType.PortableDocFormat)
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Dim b(st.Length) As Byte
st.Read(b, 0, st.Length)
Response.BinaryWrite(b)
Response.End()

I've also read this document
(http://support.businessobjects.com/library/kbase/articles/c2013539.asp)
which states you can't use SetParameterValue() method to pass multiple
values.

So anyone got any ideas how i can? Or is it possible to export my
CrystalReportViewer to PDF?

Many thanks in advance for any suggestions.

Dan Williams.
 
D

dan_williams

OK, think i've managed to solve this one myself.

All you need to do is pass the crParameterValues to the ReportDocuments

SetParameterValue function


i.e. oRpt.SetParameterValue("InvNos", crParameterValues)

Thanks anyway

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top