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 1 1872
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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,...
|
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...
|
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...
|
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...
|
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...
|
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 /*...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |