473,466 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

parameter ignored for ExportToStream ASP.NET

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\\Specimen Report.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("SpecimenA ctId")
parameterValues = parameterFieldDef.CurrentValues
parameterValues.Add(pDv)
parameterFieldDef.ApplyCurrentValues(parameterValu es)

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
Jul 21 '05 #1
1 1875
First, make sure your parameters are correct or not. That's my best bet right now.

I think you can just use the crystal reports objects as well.

Secondly,
in your if statement, you redirect, then clear the headers. the moment you redirect, you exit that thread. fyi: bad code.
"Radx" wrote:
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 C Else

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

myReport.Load("c:\\inetpub\\wwwroot\\XZY\\Specimen Report.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("SpecimenA ctId")
parameterValues = parameterFieldDef.CurrentValues
parameterValues.Add(pDv)
parameterFieldDef.ApplyCurrentValues(parameterValu es)

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

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: baumann | last post by:
hi all, Nontype template parameters are declared much like variables, but they cannot have nontype specifiers like static, mutable, and so forth. They can have const and volatile qualifiers,...
4
by: Michael C | last post by:
I was looking over some code that calls a stored procedure from C#. I have specified one more parameter than necessary but the code still works. Does anyone know why it works? This is on a PDA...
1
by: Radx | last post by:
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...
0
by: ashok.ponnusamy | last post by:
hi, i was created crystal report in my aspx. it's work fine. but i want to change the parameter value by selecting value from dropdownlist in the aspx page. First time it's work fine.second time...
0
by: Radx | last post by:
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...
5
by: Roy Smith | last post by:
I've got some legacy code I'm maintaining. There's a method declared in the class.h file like this: void foo(unsigned priority); and it's implemented as: void myClass::foo (unsigned /*...
0
by: lrobo01 | last post by:
I'm having a problem with Crystal report.net with ASP.NET. The problem occurs when exporting the report. The report uses a discrete parameter with multiple values. When the report is loaded into...
0
by: lrobo01 | last post by:
I'm having a problem with Crystal report.net with ASP.NET. The problem occurs when exporting the report. The report uses a discrete parameter with multiple values. When the report is loaded into...
1
by: harikrish | last post by:
HI im facing a problem that when i export my crystal reports to pdf format using ReportDocument object's ExportToStream method, it led me the error message that Method...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.