Programmatically Alter Values in Select Expert
Hi All,
I have this program that can let the user print the crystal report from my
asp.net application. It works find with report without need to alter query
value.
but some reports need to be compilie based on different values (specify in
SELECT EXPERT) each time it is run. How do i write my codes to do that?
Many thanks in advance for any help
below is my code for the simple export to PDF file:
----------------------------------------------------------------------------
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Shared
Imports System.IO
Public Class ReportPrinter
Inherits System.Web.UI.Page
Public crReportDocument As ReportDocument
Public crExportOptions As ExportOptions
Public crDiskFileDestinationOptions As DiskFileDestinationOptions
Public Fname As String
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
'<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
'End Sub
Public Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
' InitializeComponent()
crReportDocument = New ReportDocument()
crReportDocument.Load("C:\Inetpub\wwwroot\CrystalW eb\CrystalReport\QtyOnHand
QtyAvailable.rpt")
Fname = "C:\Inetpub\wwwroot\CrystalWeb\Download\" &
Session.SessionID.ToString & ".pdf"
crDiskFileDestinationOptions = New DiskFileDestinationOptions()
crDiskFileDestinationOptions.DiskFileName = Fname
crExportOptions = crReportDocument.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
Try
crReportDocument.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(Fname)
Response.Flush()
Response.Close()
System.IO.File.Delete(Fname)
Catch err As Exception
Response.Write("<BR><BR>")
Response.Write(err.Message.ToString)
Response.Write("<BR><BR>")
Response.Write(err.StackTrace.ToString)
End Try
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
End Class
Bernard Goh
IT Administrator
|