Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2005
    Posts
    91

    Unanswered: Crystal Report Viewer

    Hi everyone, I am looking for a quick and dirty way for users to be able to pass parameters to a crystal report without having to create a front end form in VB. Is this possible through a crystal report viewer program or would I only be able to view static reports with this program?

  2. #2
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Quote Originally Posted by dsmbwoy
    Hi everyone, I am looking for a quick and dirty way for users to be able to pass parameters to a crystal report without having to create a front end form in VB. Is this possible through a crystal report viewer program or would I only be able to view static reports with this program?
    You can use stored proc or straight away tables or queries to create reports.
    If you are using Stored proc and passing parameter to that stored proc ,the parameter toolbar will come while you are viewing the report in the reportviewer. And if you want to set parameter at report ,you can create parameter in crystal report.
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

  3. #3
    Join Date
    Nov 2005
    Posts
    91
    So it is possible to pass a parameter through a crystal report viewer program. I assumed that a report viewer program only allowed the user to view static reports. Can you recommend me to any good report viewer programs? Thanks.

  4. #4
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Quote Originally Posted by dsmbwoy
    So it is possible to pass a parameter through a crystal report viewer program. I assumed that a report viewer program only allowed the user to view static reports. Can you recommend me to any good report viewer programs? Thanks.
    It is possible and its easy to use.If you are using VB.Net ,then here is the code
    ...
    Make Stored proc with two input parameters...and create a Report with that stored proc. Then name that report as "PaymentReport"
    Open a webform>drag a Crystal Report Viewer ,name it Crystalreportviewer2>paste this code on the form> Take anothwer web form >take a button on it> pass the Session("ReportType") = "BusinessPromotion">
    and then call the report form by response.redirect("webform1.aspx")
    And you are in heaven....Test it and enjoy..
    Code:
    Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
    
      Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
    
            
            InitializeComponent()
            Session("ReportType") = "BusinessPromotion"
            Select Case Session("ReportType")
           
                Case "PCouponReport"
                    Dim crpt As PaymentReport
                    crpt = New PaymentReport
    
                    CrystalReportViewer2.DisplayGroupTree = False
                    For Each myTable In crpt.Database.Tables
                        myLogin = myTable.LogOnInfo
                        myLogin.ConnectionInfo.Password = "Yourpassword"
                        myLogin.ConnectionInfo.UserID = "sa"
                        myLogin.ConnectionInfo.DatabaseName = "databasename"
                        myTable.ApplyLogOnInfo(myLogin)
                    Next
                    
    
                    CrystalReportViewer2.ReportSource = crpt
    ----Set parameters here 
    
                    crpt.SetParameterValue(0, 39099)
                    crpt.SetParameterValue(1, 10)
    
    
                    Dim oStream As New MemoryStream
                    oStream = crpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)
                    Response.Clear()
                    Response.Buffer = True
                    Response.ContentType = "application/pdf"
    
                    Try
    
                        Response.BinaryWrite(oStream.ToArray())
                        Response.End()
                    Catch err As Exception
                        Response.Write("< BR >")
    
                    End Try
    
                
    
            End Select
    
        End Sub
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •