parameter ignored for ExportToStream ASP.NET

R

Radx

Hello All

I am having a very hard timt exporting crystal report to PDF document
in my ASPX page. I am able to generate the PDF document , but the i
am not able to pass the parameter to the report (Crystal). It looks
like , it completely ignores the parameter i am passing and just
brings all the records from the database.
When i run the report directly from Crystal , it works fine. So I
know report works fine . For some strange reason , the parameter i
am passing are not applied to the report.
Can anyone share your ideas of how to do this !!!.. Thank you

Here is the code

Dim SActivityID As Long = 0
Dim iAppUserId As Long = 0
Dim myReport As ReportDocument = New ReportDocument
Dim s As Stream
Dim crConnectionInfo As CrystalDecisions.Shared.ConnectionInfo
Dim pDv As ParameterDiscreteValue = New ParameterDiscreteValue
Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
Dim crTables As CrystalDecisions.CrystalReports.Engine.Tables
Dim crTableLogOnInfo As CrystalDecisions.Shared.TableLogOnInfo
Dim crDatabase As
CrystalDecisions.CrystalReports.Engine.Database
Dim parameterFieldDef As ParameterFieldDefinition
Dim parameterValues As ParameterValues
Dim ExpOptions As ExportOptions
Dim req As ExportRequestContext


iAppUserId = CLng(Session("SSXYUser_ID"))
If Not IsPostBack Then
If iAppUserId <= 0 Then
Response.Redirect("Login.aspx")
Response.ClearHeaders()
Else

crConnectionInfo = New
CrystalDecisions.Shared.ConnectionInfo
crConnectionInfo.ServerName = "XXXXXX"
crConnectionInfo.DatabaseName = "YYYYYYYYYYY"
crConnectionInfo.UserID = "NO"
crConnectionInfo.Password = "VVVVVVVV"

myReport.Load("c:\\inetpub\\wwwroot\\XZY\\SpecimenReport.rpt")
crDatabase = myReport.Database
crTables = crDatabase.Tables

For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next

SActivityID = CLng(Request.Params("SpecimenActID"))
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "application/pdf"
pDv.Value = SActivityID

parameterFieldDef =
myReport.DataDefinition.ParameterFields("SpecimenActId")
parameterValues = parameterFieldDef.CurrentValues
parameterValues.Add(pDv)
parameterFieldDef.ApplyCurrentValues(parameterValues)

req = New ExportRequestContext
ExpOptions = New ExportOptions
ExpOptions.ExportFormatType =
ExportFormatType.PortableDocFormat
ExpOptions.FormatOptions = New PdfRtfWordFormatOptions

req.ExportInfo = ExpOptions

s = myReport.FormatEngine.ExportToStream(req)
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "application/pdf"

Dim buffer(s.Length) As Byte
s.Read(buffer, 0, Int(s.Length))
Response.BinaryWrite(buffer)
Response.End()


End If
 
H

Haitham Aldaqqaq

Radx,

In your Crystal report Designer, you need to copy the formula Filter
From (Report >> Edit Selection Formula >> Record... )
TO (Report >> Edit Selection Formula >> Group...)

Haitham Aldaqqaq
Medcor, Inc.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top