Site Feedback Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Oracle, Crystal Reports and visual Studio 2010

Back to Forum: Site Feedback
  • User profile image

    Can anyone help me with the code for this application?

    My aim is to display reports, created with crystal reports, on a webpage after users enter a date range(generated by a sql form). The data for the report is stored in a query in an Oracle database.


    1.  the report is expected to generate new data based on the date range entered or if the data in the tables, that were used to create the query, changes.

    2.  the report is activated by a button click on the web form.


  • User profile image

    The date ranges should be made in Crystal Reports as parameters and the Record Selector to apply these parameters as a filter for your records.

    Once you have the Crystal Report so you can run it, apply your criteria and get back what you want then you can set up the display page.

    I use 2 pages; one to collect the parameters and one to display the page.

    The process I use, as an overview, is

    1. Create the object
    2. Create and apply the parameters
    3. Export the report to a temporary location (as a .pdf)
    4. Display the report to the user
    5. Remove the .pdf file

    Imports CrystalDecisions.Shared
    Imports CrystalDecisions.CrystalReports.Engine
    Dim crpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
    Dim paramFields As New CrystalDecisions.Shared.ParameterFields
    Dim paramField As New CrystalDecisions.Shared.ParameterField
    Dim dVal As New CrystalDecisions.Shared.ParameterDiscreteValue
    ' I use a session variable to store the object
    crpt.Load(objReport.ReportFullName, OpenReportMethod.OpenReportByDefault)
    Dim pvParamValues As ParameterValues
    Dim dvDiscreteValue As New ParameterDiscreteValue
    pvParamValues = crpt.DataDefinition.ParameterFields(<<parametername>>).CurrentValues
    dvDiscreteValue.Value = <<parametervalue>>
    'Log in
    Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
    Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo
    For Each myTable In crpt.Database.Tables
        myLogin = myTable.LogOnInfo
    Dim crExportOptions As New ExportOptions
    Dim crDiskFileDestinationOptios As New DiskFileDestinationOptions
    Dim fname As String = ""
    Dim gFileId As New Guid
    fname=<<wheretosavefile>> + gFileId.ToString + ".pdf"
    crExportOptions = crpt.ExportOptions
    crpt.ExportOptions.DestinationOptions = crDiskFileDestinationOptios
    crpt.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
    crpt.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
    'Display and Cleanup (comment out to debug)
    Response.ContentType = "application/pdf"
    Response.WriteFile(fname)    'writes out PDF if created

    Unfortunately I have to leave until tomorrow. Have fun!

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.