473,320 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem with adding parameter

I am trying to move from having a crystalreportviewer to just
launching the PDF, but have difficulties adding a parameter value for
the underlying stored procedure

The commented-out part works in another context and I'm trying to make
it fit in, but can't see through it.

Thanks a bunch for any help!

Regards /Snedker

'--code begin
crReportDocument = New ReportDocument()

crReportDocument.Load(Server.MapPath("Reports\Erkl aering.rpt"))
Fname = "c:\exports\" & Session("vvsID") & ".pdf"

'Dim field1 As ParameterField =
Me.CrystalReportViewer1.ParameterFieldInfo(0)
'Dim val1 As ParameterDiscreteValue = New
ParameterDiscreteValue
'val1.Value = Session("vvsID")
'field1.CurrentValues.Add(val1)
crDiskFileDestinationOptions = New
DiskFileDestinationOptions()
crDiskFileDestinationOptions.DiskFileName = Fname
crExportOptions = crReportDocument.ExportOptions

With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With

crReportDocument.Export()

Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(Fname)
Response.Flush()
Response.Close()
System.IO.File.Delete(Fname)
'--code end
--
http://www.dbconsult.dk
http://www.vinthervej2.dk [private]
Feb 1 '07 #1
1 923
On Thu, 01 Feb 2007 14:17:01 +0100, Morten Snedker
<morten_spammenot_ATdbconsult.dkwrote:

Got it to work. Finally!

Maybe someone else can enjoy the code it took me hours and hours to
generate.

Printing to PDF without using CrystalReportViewer and with parameter
on the underlying stored procedure:

Sub PDFExport()

Dim crReportDocument As ReportDocument
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim Fname As String

Try

Dim dv As New ParameterDiscreteValue
dv.Value = Session("vvsID")

crReportDocument = New ReportDocument()

crReportDocument.Load(Server.MapPath("Reports\Erkl aering.rpt"))
crReportDocument.SetParameterValue(0, dv.Value)
crReportDocument.SetDatabaseLogon("somename", "pass",
"yourserver", "databasename")
Fname = "c:\exports\" & Session("vvsID").ToString & ".pdf"

crDiskFileDestinationOptions = New
DiskFileDestinationOptions()
crDiskFileDestinationOptions.DiskFileName = Fname
crExportOptions = crReportDocument.ExportOptions

With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType =
ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With

crReportDocument.Export()

Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(Fname)
Response.Flush()
Response.Close()
System.IO.File.Delete(Fname)
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Now it just needs to be moved to a reusable class.

cheers!
--
http://www.dbconsult.dk
http://www.vinthervej2.dk [private]
Feb 1 '07 #2

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

Similar topics

49
by: Mark Hahn | last post by:
As we are addressing the "warts" in Python to be fixed in Prothon, we have come upon the mutable default parameter problem. For those unfamiliar with the problem, it can be seen in this Prothon...
4
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a...
5
by: Jason Huang | last post by:
Hi, The SqlParameter myPM =new SqlParameter("@Address", txtAddress.Text) is working for update, but SqlParameter myPM =new SqlParameter ("@Address",SqlDbType.NVarChar,90,txtAddress.Text) is...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
2
by: Bernard Bourée | last post by:
I have defined a Class called EntSor (see code ) with a procedure Sub Définit which assign the values of this class. Then I have defined an Arraylist with Dim colEntSor As New ArrayList() ...
3
by: ryan.mitchley | last post by:
Hi all I have a class (cPort) that is designed to receive objects and, depending on the type, call a handler (callback) in any descendant of a cProcessBlock class. Callback functions take a...
0
by: Fred Dag | last post by:
Hi, I have a FormView that uses a ObjectDataSource. It retreives data alright but when updating it gives a ObjectDataSource 'ObjectDataSourceCatalogueItem' could not find a non-generic method...
1
by: napolpie | last post by:
----Messaggio originale---- Da: napolpie@tin.it Data: 3-mag-2007 10.02 A: <python-list@python.org> Ogg: problem with meteo datas Hello, I'm Peter and I'm new in python codying and I'm using...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
0
by: fig000 | last post by:
Hi, I'm using an objectdatasource. The insert procedure called by the objectdatasource is in a separate library file outside of the aspx and the codebehind that is using the objectdatasource in...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.